Fixed various NPEs and OutOfBounds querying metadata