Move to using callback functions instead of events