Fixed bug with improper casting of boolean metadata field to an actual boolean.
Heavy handed refactoring of Metadata and Metadatafield class.