preliminary querying system
Fix bugs
Add typechecking to queries
Add queries