Separated drawin/event-handling logic to MainLoop class.