Added more abstractions for data types and made filter_events functional