implemented simple event-based chat client. cleaned code