Refactored to remove unsafe .gets, remove pattern matching edge cases, make error messages more explicit, remove unnecessary boxing from lookupSchema.
/cc @jbeemster