De-duplicate filter code.