improved copy/move code