added framework for title display and cleaned up event handling code