organizing files, adding event handling and main loop