Adding validation checks to the filtering and ordering arguments.
Changing the query methods to interacting directly with the DB's cursors.