Fix longstanding bug in metadata deepcopy.
Works, and made it substantially faster too.
Merge pull request #92 from cbhaley/master

Fix longstanding bug in metadata deepcopy.