Restructure game code