Code formatting and cleanup
Adding unit tests for query functionality.
Removing unused code.