Code cleanup - beforeFilter and afterFilter events