Refactor and clean up admin filter code