Fixed bug in writing undefined metadata.