fix a copy/move bug amongst other things original patch from Bryan Linton <bl at shoshoni dot info>, thanks