Added some error checking in the metadata manager code.