Exit with error code if the metadata is invalid

Also fix typos.