Implement the getFilterOptions and searchFor function.
Fix a wrong select query. Cleanup code.