Code gen copy constructor

Added copy constructor for code generated objects. Not tested yet.