Resolved an issue about not being able to use instance variables in event handler functions