Added copy function for entities