Structured the code and files, created eventloop etc.