Refactor code for SQL filters to make it easier to change.
More code cleanup and commenting.
Optimised input controller to return results quickly.