Fixed write_metadata/create_metadata methods