Moved the timer tick listener to an inner class.