Major bug fixes. Metadata / util functions added

Much needed boilerplate utility code and metadata handling has been
added. Instead of breaking when metadata is missing, we always check if
it exists now with hasMetaData(player,"key")!