Start refactor events model and main_loop