Adding support for user queries

This fixes #139, and provides the user query mechanism. Lays the groundwork for cool features built on the query support.