Query Factories

Added query factories that will produce queries for each object that is added.
Some other minor fixes.