Refactored MetadataWriter into separate class
Merged rlau changes with MetadataWriter changes