Cleaning up event based code