Added main loop using timer events.