Fix filter fields, clean up code