diff --git a/cmake/libsuperderpy.cmake b/cmake/libsuperderpy.cmake
index 38c3a6c..c7c59c1 100644
--- a/cmake/libsuperderpy.cmake
+++ b/cmake/libsuperderpy.cmake
@@ -144,7 +144,7 @@ if(ANDROID)
     configure_android_file("project.properties" @ONLY)
     configure_android_file("res/values/strings.xml")
     configure_android_file("jni/localgen.mk")
-    if (ALLEGRO5_LIBRARIES MATCHES "^.*-debug$")
+    if (ALLEGRO5_LIBRARIES MATCHES "^.*-debug.*$")
 	configure_file("${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.debug.in" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java")
     else()
 	configure_file("${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java.in" "${CMAKE_BINARY_DIR}/android/src/net/dosowisko/libsuperderpy/SuperDerpyActivity.java")
diff --git a/src/internal.c b/src/internal.c
index 0c2323c..02b89b9 100644
--- a/src/internal.c
+++ b/src/internal.c
@@ -24,8 +24,8 @@
 #include "libsuperderpy.h"
 
 SYMBOL_INTERNAL void DrawGamestates(struct Game *game) {
+	ClearScreen(game);
 	al_set_target_backbuffer(game->display);
-	al_clear_to_color(al_map_rgb(0,0,0));
 	struct Gamestate *tmp = game->_priv.gamestates;
 	while (tmp) {
 		if ((tmp->loaded) && (tmp->started)) {
@@ -175,3 +175,16 @@ SYMBOL_INTERNAL void ClearGarbage(struct Game *game) {
 		game->_priv.garbage = tmp;
 	}
 }
+
+SYMBOL_INTERNAL void ClearScreen(struct Game *game) {
+	ALLEGRO_TRANSFORM identity;
+	int clipX, clipY, clipWidth, clipHeight;
+	al_set_target_backbuffer(game->display);
+	al_get_clipping_rectangle(&clipX, &clipY, &clipWidth, &clipHeight);
+	al_set_clipping_rectangle(0, 0, al_get_display_width(game->display), al_get_display_height(game->display));
+	al_identity_transform(&identity);
+	al_use_transform(&identity);
+	al_clear_to_color(al_map_rgb(0,0,0));
+	al_use_transform(&game->projection);
+	al_set_clipping_rectangle(clipX, clipY, clipWidth, clipHeight);
+}
diff --git a/src/internal.h b/src/internal.h
index fc51078..036dd79 100644
--- a/src/internal.h
+++ b/src/internal.h
@@ -52,5 +52,6 @@ void Console_Unload(struct Game *game);
 void GamestateProgress(struct Game *game);
 void* AddGarbage(struct Game *game, void* data);
 void ClearGarbage(struct Game *game);
+void ClearScreen(struct Game *game);
 
 #endif
diff --git a/src/libsuperderpy.c b/src/libsuperderpy.c
index e7ab1d4..c5d9ecc 100644
--- a/src/libsuperderpy.c
+++ b/src/libsuperderpy.c
@@ -255,9 +255,8 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
 
 	while(1) {
 		// TODO: split mainloop to functions to make it readable
-
 		ALLEGRO_EVENT ev;
-		if ((game->_priv.draw && redraw && al_is_event_queue_empty(game->_priv.event_queue)) || (game->_priv.gamestate_scheduled)) {
+		if (game->_priv.draw && ((redraw && al_is_event_queue_empty(game->_priv.event_queue)) || (game->_priv.gamestate_scheduled))) {
 
 			game->_priv.gamestate_scheduled = false;
 			struct Gamestate *tmp = game->_priv.gamestates;
@@ -398,15 +397,16 @@ SYMBOL_EXPORT int libsuperderpy_run(struct Game *game) {
 				SetupViewport(game, game->viewport_config);
 			}
 			else if(ev.type == ALLEGRO_EVENT_DISPLAY_HALT_DRAWING) {
-				al_stop_timer(game->_priv.timer);
 				game->_priv.draw = false;
+				al_stop_timer(game->_priv.timer);
 				al_detach_voice(game->audio.v);
 				al_acknowledge_drawing_halt(game->display);
+				continue;
 			}
 			else if(ev.type == ALLEGRO_EVENT_DISPLAY_RESUME_DRAWING) {
-				al_acknowledge_drawing_resume(game->display);
 				al_attach_mixer_to_voice(game->audio.mixer, game->audio.v);
 				game->_priv.draw = true;
+				al_acknowledge_drawing_resume(game->display);
 				al_resume_timer(game->_priv.timer);
 				SetupViewport(game, game->viewport_config);
 			}
@@ -497,7 +497,7 @@ SYMBOL_EXPORT void libsuperderpy_destroy(struct Game *game) {
 		tmp=pom;
 	}
 
-	al_clear_to_color(al_map_rgb(0,0,0));
+	ClearScreen(game);
 	PrintConsole(game, "Shutting down...");
 	DrawConsole(game);
 	al_flip_display();
diff --git a/src/utils.c b/src/utils.c
index 9315b04..8edb5b7 100644
--- a/src/utils.c
+++ b/src/utils.c
@@ -324,6 +324,7 @@ SYMBOL_EXPORT void PrintConsole(struct Game *game, char* format, ...) {
 	vsnprintf(text, 1024, format, vl);
 	va_end(vl);
 	if (game->config.debug) { printf("%s\n", text); fflush(stdout); }
+	if (!game->_priv.draw) return;
 	if (!game->_priv.console) return;
 	if ((!game->config.debug) && (!game->_priv.showconsole)) return;
 	al_set_target_bitmap(game->_priv.console_tmp);
@@ -354,10 +355,6 @@ SYMBOL_EXPORT void SetupViewport(struct Game *game, struct Viewport config) {
 	al_use_transform(&game->projection);
 	al_set_clipping_rectangle(0, 0, al_get_display_width(game->display), al_get_display_height(game->display));
 
-	al_clear_to_color(al_map_rgb(0,0,0));
-	al_flip_display();
-	al_clear_to_color(al_map_rgb(0,0,0));
-
 	float resolution = al_get_display_width(game->display) / (float)game->viewport.width;
 	if (al_get_display_height(game->display) / game->viewport.height < resolution) resolution = al_get_display_height(game->display) / (float)game->viewport.height;
 	if (game->viewport.integer_scaling) {