Implementation of a deepCopy method