Shorten main game loop still more using functions.