Added more comments, decoupled gameloop and endgame