some optimisations
deep copy map when toMap is called