Cleaned up file metadata creation and added some checks
for metadata version.