Created modules, more events, moved some code, handles incoming messages