Fixed warnings. Implemented the base of the event driven main loop.

Fixed up current warnings.
Implemented the base of the event driven main loop.