Moved all to mainLoop and self