Mouse/keyboard event handling cleanup