fixed an issue where event handlers, e.g. mouseClicked, would hang around after restarting the program even after being removed from the code