Exit with error code if the metadata is invalid

Also fix typos.
Merge pull request #29 from tmatilai/exit-on-corrupted-metadata

Exit with error code if the metadata is invalid