Some refactoring, still problems with the event handler