added a tiny bit of type safety around some things like getMetadata, so there should be fewer runtime crashes now