minor fixes and deep copy of objects when duplicate