#include "gui/menu_manager.hpp"
 #include "gui/mousecursor.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/resources.hpp"
 #include "supertux/timer.hpp"
 #include "util/gettext.hpp"
 
 #include "object/endsequence_fireworks.hpp"
 
 #include "object/fireworks.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/globals.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/sector.hpp"
 
 EndSequenceFireworks::EndSequenceFireworks() :
 EndSequenceFireworks::starting()
 {
   EndSequence::starting();
-  endsequence_timer.start(7.3f * g_main_loop->get_speed());
+  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
   Sector::current()->add_object(new Fireworks());
 }
 
 
 
 #include "object/endsequence_walkleft.hpp"
 #include "object/player.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/globals.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/sector.hpp"
 
 EndSequenceWalkLeft::EndSequenceWalkLeft() :
 {
   EndSequence::starting();
   last_x_pos = -1;
-  endsequence_timer.start(7.3f * g_main_loop->get_speed());
+  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
 }
 
 void
 
 
 #include "object/endsequence_walkright.hpp"
 #include "object/player.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/globals.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/sector.hpp"
 
 EndSequenceWalkRight::EndSequenceWalkRight() :
 {
   EndSequence::starting();
   last_x_pos = -1;
-  endsequence_timer.start(7.3f * g_main_loop->get_speed());
+  endsequence_timer.start(7.3f * g_screen_manager->get_speed());
 }
 
 void
 
 #include "supertux/game_session.hpp"
 #include "supertux/gameconfig.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/sector.hpp"
 #include "supertux/shrinkfade.hpp"
 #include "supertux/textscroller.hpp"
 
 void wait_for_screenswitch(HSQUIRRELVM vm)
 {
-  g_main_loop->waiting_threads.add(vm);
+  g_screen_manager->waiting_threads.add(vm);
 }
 
 void exit_screen()
 {
-  g_main_loop->exit_screen();
+  g_screen_manager->exit_screen();
 }
 
 void fadeout_screen(float seconds)
 {
-  g_main_loop->set_screen_fade(new FadeOut(seconds));
+  g_screen_manager->set_screen_fade(new FadeOut(seconds));
 }
 
 void shrink_screen(float dest_x, float dest_y, float seconds)
 {
-  g_main_loop->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds));
+  g_screen_manager->set_screen_fade(new ShrinkFade(Vector(dest_x, dest_y), seconds));
 }
 
 void abort_screenfade()
 {
-  g_main_loop->set_screen_fade(NULL);
+  g_screen_manager->set_screen_fade(NULL);
 }
 
 std::string translate(const std::string& text)
 
 void display_text_file(const std::string& filename)
 {
-  g_main_loop->push_screen(new TextScroller(filename));
+  g_screen_manager->push_screen(new TextScroller(filename));
 }
 
 void load_worldmap(const std::string& filename)
 {
   using namespace WorldMapNS;
 
-  g_main_loop->push_screen(new WorldMap(filename));
+  g_screen_manager->push_screen(new WorldMap(filename));
 }
 
 void load_level(const std::string& filename)
 {
-  g_main_loop->push_screen(new GameSession(filename));
+  g_screen_manager->push_screen(new GameSession(filename));
 }
 
 static SQInteger squirrel_read_char(SQUserPointer file)
 
 void quit()
 {
-  g_main_loop->quit();
+  g_screen_manager->quit();
 }
 
 int rand()
 
 int SCREEN_WIDTH;
 int SCREEN_HEIGHT;
 
+ScreenManager* g_screen_manager = NULL;
+
+TextureManager* texture_manager = NULL;
+
 /* EOF */
 
 
 #include <SDL.h>
 
+class JoystickKeyboardController;
+class ScreenManager;
+class TextureManager;
+
 /** The width of the display (this is a logical value, not the
     physical value, since aspect_ration and projection_area might
     shrink or scale things) */
 extern int SCREEN_HEIGHT;
 
 // global variables
-class  JoystickKeyboardController;
 extern JoystickKeyboardController* g_main_controller;
 
 extern SDL_Surface* g_screen;
 
+extern ScreenManager* g_screen_manager;
+
+extern TextureManager* texture_manager;
+
 #endif
 
 /* EOF */
 
 
 #include "audio/sound_manager.hpp"
 #include "gui/menu_item.hpp"
+#include "supertux/globals.hpp"
 #include "supertux/screen_manager.hpp"
 #include "supertux/title_screen.hpp"
 #include "supertux/world.hpp"
 
 
 float g_game_speed = 1.0f;
 
-ScreenManager* g_screen_manager = NULL;
-
 ScreenManager::ScreenManager() :
   waiting_threads(),
   running(),
 
   bool screenshot_requested; /**< true if a screenshot should be taken after the next frame has been rendered */
 };
 
-extern ScreenManager* g_screen_manager;
-
 #endif
 
 /* EOF */
 
 #include "physfs/ifile_stream.hpp"
 #include "scripting/serialize.hpp"
 #include "scripting/squirrel_util.hpp"
+#include "supertux/globals.hpp"
 #include "supertux/screen_manager.hpp"
 #include "supertux/player_status.hpp"
 #include "supertux/world.hpp"
 
 Surface::Surface(const std::string& file) :
   texture(texture_manager->get(file)),
   surface_data(),
-  x(0), y(0), w(0), h(0),
+  x(0),
+  y(0), 
+  w(0), 
+  h(0),
   flipx(false)
 {
   texture->ref();
 Surface::Surface(const std::string& file, int x, int y, int w, int h) :
   texture(texture_manager->get(file)),
   surface_data(),
-  x(x), y(y), w(w), h(h),
+  x(x), 
+  y(y),
+  w(w),
+  h(h),
   flipx(false)
 {
   texture->ref();
 Surface::Surface(const Surface& other) :
   texture(other.texture),
   surface_data(),
-  x(other.x), y(other.y),
-  w(other.w), h(other.h),
+  x(other.x), 
+  y(other.y),
+  w(other.w), 
+  h(other.h),
   flipx(false)
 {
   texture->ref();
 }
 
 const Surface& 
-Surface::operator= (const Surface& other)
+Surface::operator=(const Surface& other)
 {
   other.texture->ref();
   texture->unref();
 
 #include <assert.h>
 #include <string>
 
+#include "supertux/globals.hpp"
 #include "video/texture_manager.hpp"
 
 /// bitset for drawing effects
 
 #include "video/gl/gl_texture.hpp"
 #include "video/video_systems.hpp"
 
-TextureManager* texture_manager = NULL;
-
 TextureManager::TextureManager() :
   image_textures()
 #ifdef HAVE_OPENGL
 
 #endif
 };
 
-extern TextureManager* texture_manager;
-
 #endif
 
 /* EOF */
 
 #include "sprite/sprite_manager.hpp"
 #include "supertux/game_session.hpp"
 #include "supertux/globals.hpp"
-#include "supertux/mainloop.hpp"
+#include "supertux/screen_manager.hpp"
 #include "supertux/menu/menu_storage.hpp"
 #include "supertux/menu/options_menu.hpp"
 #include "supertux/menu/worldmap_menu.hpp"
 void
 WorldMap::change(const std::string& filename, const std::string& force_spawnpoint)
 {
-  g_main_loop->exit_screen();
-  g_main_loop->push_screen(new WorldMap(filename, force_spawnpoint));
+  g_screen_manager->exit_screen();
+  g_screen_manager->push_screen(new WorldMap(filename, force_spawnpoint));
 }
 
 void
             MenuManager::set_current(0);
             break;
           case MNID_QUITWORLDMAP: // Quit Worldmap
-            g_main_loop->exit_screen();
+            g_screen_manager->exit_screen();
             break;
         }
       }
           // update state and savegame
           save_state();
 
-          g_main_loop->push_screen(new GameSession(levelfile, &level->statistics),
+          g_screen_manager->push_screen(new GameSession(levelfile, &level->statistics),
                                    new ShrinkFade(shrinkpos, 1.0f));
           in_level = true;
         } catch(std::exception& e) {