Move all AOSP code out of recovery binary

Improves license compatibility between GPL and Apache

Change-Id: I2b165aa575bb6213af6b07936f99610c113443f0
diff --git a/gui/Android.mk b/gui/Android.mk
index b3e9b09..748c5ec 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -30,7 +30,7 @@
   LOCAL_SRC_FILES += hardwarekeyboard.cpp
 endif
 
-LOCAL_MODULE := libgui
+LOCAL_MODULE := libguitwrp
 
 # Use this flag to create a build that simulates threaded actions like installing zips, backups, restores, and wipes for theme testing
 #TWRP_SIMULATE_ACTIONS := true
diff --git a/gui/action.cpp b/gui/action.cpp
index 3456324..b35074c 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -38,17 +38,15 @@
 #include "../twrp-functions.hpp"
 #include "../openrecoveryscript.hpp"
 
-#include "../ui.h"
 #include "../adb_install.h"
 #include "blanktimer.hpp"
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 #include "../variables.h"
 #include "../twinstall.h"
-
+#include "cutils/properties.h"
 #include "../minadbd/adb.h"
 
 int TWinstall_zip(const char* path, int* wipe_cache);
@@ -60,7 +58,6 @@
 #include "rapidxml.hpp"
 #include "objects.hpp"
 
-extern RecoveryUI* ui;
 extern blanktimer blankTimer;
 
 void curtainClose(void);
@@ -160,7 +157,7 @@
 
 void GUIAction::simulate_progress_bar(void)
 {
-	ui_print("Simulating actions...\n");
+	gui_print("Simulating actions...\n");
 	for (int i = 0; i < 5; i++)
 	{
 		usleep(500000);
@@ -176,7 +173,7 @@
 
     if (filename.empty())
     {
-        LOGE("No file specified.\n");
+        LOGERR("No file specified.\n");
         return -1;
     }
 
@@ -191,7 +188,7 @@
 
 	if (mzOpenZipArchive(filename.c_str(), &zip))
     {
-        LOGE("Unable to open zip file.\n");
+        LOGERR("Unable to open zip file.\n");
         return -1;
     }
 
@@ -231,10 +228,10 @@
 		{
 			DataManager::SetValue("tw_operation", "Configuring TWRP");
 			DataManager::SetValue("tw_partition", "");
-			ui_print("Configuring TWRP...\n");
+			gui_print("Configuring TWRP...\n");
 			if (TWFunc::Exec_Cmd("/sbin/installTwrp reinstall", result) < 0)
 			{
-				ui_print("Unable to configure TWRP with this kernel.\n");
+				gui_print("Unable to configure TWRP with this kernel.\n");
 			}
 		}
 	}
@@ -256,33 +253,33 @@
 	pthread_attr_t tattr;
 
 	if (pthread_attr_init(&tattr)) {
-		LOGE("Unable to pthread_attr_init\n");
+		LOGERR("Unable to pthread_attr_init\n");
 		return -1;
 	}
 	if (pthread_attr_setdetachstate(&tattr, PTHREAD_CREATE_JOINABLE)) {
-		LOGE("Error setting pthread_attr_setdetachstate\n");
+		LOGERR("Error setting pthread_attr_setdetachstate\n");
 		return -1;
 	}
 	if (pthread_attr_setscope(&tattr, PTHREAD_SCOPE_SYSTEM)) {
-		LOGE("Error setting pthread_attr_setscope\n");
+		LOGERR("Error setting pthread_attr_setscope\n");
 		return -1;
 	}
 	/*if (pthread_attr_setstacksize(&tattr, 524288)) {
-		LOGE("Error setting pthread_attr_setstacksize\n");
+		LOGERR("Error setting pthread_attr_setstacksize\n");
 		return -1;
 	}
 	*/
 	int ret = pthread_create(&t, &tattr, thread_start, this);
     if (ret) {
-		LOGE("Unable to create more threads for actions... continuing in same thread! %i\n", ret);
+		LOGERR("Unable to create more threads for actions... continuing in same thread! %i\n", ret);
 		thread_start(this);
 	} else {
 		if (pthread_join(t, NULL)) {
-			LOGE("Error joining threads\n");
+			LOGERR("Error joining threads\n");
 		}
 	}
 	if (pthread_attr_destroy(&tattr)) {
-		LOGE("Failed to pthread_attr_destroy\n");
+		LOGERR("Failed to pthread_attr_destroy\n");
 		return -1;
 	}
 
@@ -392,7 +389,7 @@
 		operation_start("Reload Theme");
 		theme_path = DataManager::GetSettingsStoragePath();
 		if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
-			LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
+			LOGERR("Unable to mount %s during reload function startup.\n", theme_path.c_str());
 			check = 1;
 		}
 
@@ -400,10 +397,10 @@
 		if (check != 0 || PageManager::ReloadPackage("TWRP", theme_path) != 0)
 		{
 			// Loading the custom theme failed - try loading the stock theme
-			LOGI("Attempting to reload stock theme...\n");
+			LOGINFO("Attempting to reload stock theme...\n");
 			if (PageManager::ReloadPackage("TWRP", "/res/ui.xml"))
 			{
-				LOGE("Failed to load base packages.\n");
+				LOGERR("Failed to load base packages.\n");
 				ret_val = 1;
 			}
 		}
@@ -446,7 +443,7 @@
 			if (!simulate)
 				PartitionManager.usb_storage_enable();
 			else
-				ui_print("Simulating actions...\n");
+				gui_print("Simulating actions...\n");
         }
         else if (!simulate)
         {
@@ -458,7 +455,7 @@
 			else
 				PartitionManager.Mount_By_Path(arg, true);
         } else
-			ui_print("Simulating actions...\n");
+			gui_print("Simulating actions...\n");
         return 0;
     }
 
@@ -469,7 +466,7 @@
             if (!simulate)
 				PartitionManager.usb_storage_disable();
 			else
-				ui_print("Simulating actions...\n");
+				gui_print("Simulating actions...\n");
 			DataManager::SetValue(TW_ACTION_BUSY, 0);
         }
         else if (!simulate)
@@ -482,7 +479,7 @@
 			else
 				PartitionManager.UnMount_By_Path(arg, true);
         } else
-			ui_print("Simulating actions...\n");
+			gui_print("Simulating actions...\n");
         return 0;
     }
 	
@@ -490,7 +487,7 @@
 	{
 		operation_start("Restore Defaults");
 		if (simulate) // Simulated so that people don't accidently wipe out the "simulation is on" setting
-			ui_print("Simulating actions...\n");
+			gui_print("Simulating actions...\n");
 		else {
 			DataManager::ResetDefaults();
 			PartitionManager.Update_System_Details();
@@ -509,7 +506,7 @@
 			dst = DataManager::GetCurrentStoragePath() + "/recovery.log";
 			TWFunc::copy_file("/tmp/recovery.log", dst.c_str(), 0755);
 			sync();
-			ui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
+			gui_print("Copied recovery log to %s.\n", DataManager::GetCurrentStoragePath().c_str());
 		} else
 			simulate_progress_bar();
 		operation_end(0, simulate);
@@ -631,7 +628,7 @@
 	if (function == "queuezip")
     {
         if (zip_queue_index >= 10) {
-			ui_print("Maximum zip queue reached!\n");
+			gui_print("Maximum zip queue reached!\n");
 			return 0;
 		}
 		DataManager::GetValue("tw_filename", zip_queue[zip_queue_index]);
@@ -645,7 +642,7 @@
 	if (function == "cancelzip")
     {
         if (zip_queue_index <= 0) {
-			ui_print("Minimum zip queue reached!\n");
+			gui_print("Minimum zip queue reached!\n");
 			return 0;
 		} else {
 			zip_queue_index--;
@@ -694,7 +691,7 @@
 
 				ret_val = flash_zip(zip_queue[i], arg, simulate, &wipe_cache);
 				if (ret_val != 0) {
-					ui_print("Error flashing zip '%s'\n", zip_queue[i].c_str());
+					gui_print("Error flashing zip '%s'\n", zip_queue[i].c_str());
 					i = 10; // Error flashing zip - exit queue
 					ret_val = 1;
 				}
@@ -707,7 +704,7 @@
 			string result;
 			if (DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
 				operation_start("ReinjectTWRP");
-				ui_print("Injecting TWRP into boot image...\n");
+				gui_print("Injecting TWRP into boot image...\n");
 				if (simulate) {
 					simulate_progress_bar();
 				} else {
@@ -718,7 +715,7 @@
 						string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
 						TWFunc::Exec_Cmd(injectcmd, result);
 					}
-					ui_print("TWRP injection complete.\n");
+					gui_print("TWRP injection complete.\n");
 				}
 			}
 			PartitionManager.Update_System_Details();
@@ -768,15 +765,15 @@
 					TWPartition* wipe_part = NULL;
 
 					DataManager::GetValue("tw_wipe_list", Wipe_List);
-					LOGI("wipe list '%s'\n", Wipe_List.c_str());
+					LOGINFO("wipe list '%s'\n", Wipe_List.c_str());
 					if (!Wipe_List.empty()) {
 						size_t start_pos = 0, end_pos = Wipe_List.find(";", start_pos);
 						while (end_pos != string::npos && start_pos < Wipe_List.size()) {
 							wipe_path = Wipe_List.substr(start_pos, end_pos - start_pos);
-							LOGI("wipe_path '%s'\n", wipe_path.c_str());
+							LOGINFO("wipe_path '%s'\n", wipe_path.c_str());
 							if (wipe_path == "/and-sec") {
 								if (!PartitionManager.Wipe_Android_Secure()) {
-									LOGE("Unable to wipe android secure\n");
+									LOGERR("Unable to wipe android secure\n");
 									ret_val = false;
 									break;
 								} else {
@@ -784,7 +781,7 @@
 								}
 							} else if (wipe_path == "DALVIK") {
 								if (!PartitionManager.Wipe_Dalvik_Cache()) {
-									LOGE("Failed to wipe dalvik\n");
+									LOGERR("Failed to wipe dalvik\n");
 									ret_val = false;
 									break;
 								} else {
@@ -793,7 +790,7 @@
 							}
 							if (!skip) {
 								if (!PartitionManager.Wipe_By_Path(wipe_path)) {
-									LOGE("Unable to wipe '%s'\n", wipe_path.c_str());
+									LOGERR("Unable to wipe '%s'\n", wipe_path.c_str());
 									ret_val = false;
 									break;
 								} else if (wipe_path == DataManager::GetSettingsStoragePath()) {
@@ -814,12 +811,12 @@
 					string Storage_Path = DataManager::GetSettingsStoragePath();
 
 					if (PartitionManager.Mount_By_Path(Storage_Path, true)) {
-						LOGI("Making TWRP folder and saving settings.\n");
+						LOGINFO("Making TWRP folder and saving settings.\n");
 						Storage_Path += "/TWRP";
 						mkdir(Storage_Path.c_str(), 0777);
 						DataManager::Flush();
 					} else {
-						LOGE("Unable to recreate TWRP folder and save settings.\n");
+						LOGERR("Unable to recreate TWRP folder and save settings.\n");
 					}
 				}
 			}
@@ -879,7 +876,7 @@
 		if (function == "fixpermissions")
 		{
 			operation_start("Fix Permissions");
-            LOGI("fix permissions started!\n");
+            LOGINFO("fix permissions started!\n");
 			if (simulate) {
 				simulate_progress_bar();
 			} else {
@@ -915,7 +912,7 @@
 				int allow_partition;
 				DataManager::GetValue(TW_ALLOW_PARTITION_SDCARD, allow_partition);
 				if (allow_partition == 0) {
-					ui_print("This device does not have a real SD Card!\nAborting!\n");
+					gui_print("This device does not have a real SD Card!\nAborting!\n");
 				} else {
 					if (!PartitionManager.Partition_SDCard())
 						ret_val = 1; // failed
@@ -963,7 +960,7 @@
 			string result;
 
 			operation_start("Command");
-			LOGI("Running command: '%s'\n", arg.c_str());
+			LOGINFO("Running command: '%s'\n", arg.c_str());
 			if (simulate) {
 				simulate_progress_bar();
 			} else {
@@ -982,19 +979,19 @@
 
 			DataManager::GetValue("tw_terminal_location", cmdpath);
 			operation_start("CommandOutput");
-			ui_print("%s # %s\n", cmdpath.c_str(), arg.c_str());
+			gui_print("%s # %s\n", cmdpath.c_str(), arg.c_str());
 			if (simulate) {
 				simulate_progress_bar();
 				operation_end(op_status, simulate);
 			} else {
 				command = "cd \"" + cmdpath + "\" && " + arg + " 2>&1";;
-				LOGI("Actual command is: '%s'\n", command.c_str());
+				LOGINFO("Actual command is: '%s'\n", command.c_str());
 				DataManager::SetValue("tw_terminal_command_thread", command);
 				DataManager::SetValue("tw_terminal_state", 1);
 				DataManager::SetValue("tw_background_thread_running", 1);
 				op_status = pthread_create(&terminal_command, NULL, command_thread, NULL);
 				if (op_status != 0) {
-					LOGE("Error starting terminal command thread, %i.\n", op_status);
+					LOGERR("Error starting terminal command thread, %i.\n", op_status);
 					DataManager::SetValue("tw_terminal_state", 0);
 					DataManager::SetValue("tw_background_thread_running", 0);
 					operation_end(1, simulate);
@@ -1006,7 +1003,7 @@
 		{
 			int op_status = 0;
 
-			LOGI("Sending kill command...\n");
+			LOGINFO("Sending kill command...\n");
 			operation_start("KillCommand");
 			DataManager::SetValue("tw_operation_status", 0);
 			DataManager::SetValue("tw_operation_state", 1);
@@ -1020,12 +1017,12 @@
 			int op_status = 0;
 			string result;
 			operation_start("ReinjectTWRP");
-			ui_print("Injecting TWRP into boot image...\n");
+			gui_print("Injecting TWRP into boot image...\n");
 			if (simulate) {
 				simulate_progress_bar();
 			} else {
 				TWFunc::Exec_Cmd("injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash", result);
-				ui_print("TWRP injection complete.\n");
+				gui_print("TWRP injection complete.\n");
 			}
 
 			operation_end(op_status, simulate);
@@ -1077,7 +1074,7 @@
 
 							theme_path = DataManager::GetSettingsStoragePath();
 							if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
-								LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
+								LOGERR("Unable to mount %s during reload function startup.\n", theme_path.c_str());
 								check = 1;
 							}
 
@@ -1086,10 +1083,10 @@
 								if (PageManager::ReloadPackage("TWRP", theme_path) != 0)
 								{
 									// Loading the custom theme failed - try loading the stock theme
-									LOGI("Attempting to reload stock theme...\n");
+									LOGINFO("Attempting to reload stock theme...\n");
 									if (PageManager::ReloadPackage("TWRP", "/res/ui.xml"))
 									{
-										LOGE("Failed to load base packages.\n");
+										LOGERR("Failed to load base packages.\n");
 									}
 								}
 							}
@@ -1121,20 +1118,23 @@
 				if (TWFunc::Path_Exists(Sideload_File)) {
 					unlink(Sideload_File.c_str());
 				}
-				ui_print("Starting ADB sideload feature...\n");
+				gui_print("Starting ADB sideload feature...\n");
 				DataManager::GetValue("tw_wipe_dalvik", wipe_dalvik);
-				ret = apply_from_adb(ui, &wipe_cache, Sideload_File.c_str());
+				ret = apply_from_adb(Sideload_File.c_str());
+				DataManager::SetValue("tw_has_cancel", 0); // Remove cancel button from gui now that the zip install is going to start
 				if (ret != 0) {
 					ret = 1; // failure
-				} else {
+				} else if (TWinstall_zip(Sideload_File.c_str(), &wipe_cache) == 0) {
 					if (wipe_cache || DataManager::GetIntValue("tw_wipe_cache"))
 						PartitionManager.Wipe_By_Path("/cache");
 					if (wipe_dalvik)
 						PartitionManager.Wipe_Dalvik_Cache();
+				} else {
+					ret = 1; // failure
 				}
 				if (DataManager::GetIntValue(TW_HAS_INJECTTWRP) == 1 && DataManager::GetIntValue(TW_INJECT_AFTER_ZIP) == 1) {
 					operation_start("ReinjectTWRP");
-					ui_print("Injecting TWRP into boot image...\n");
+					gui_print("Injecting TWRP into boot image...\n");
 					if (simulate) {
 						simulate_progress_bar();
 					} else {
@@ -1145,7 +1145,7 @@
 							string injectcmd = "injecttwrp --dump /tmp/backup_recovery_ramdisk.img /tmp/injected_boot.img --flash bd=" + Boot->Actual_Block_Device;
 							TWFunc::Exec_Cmd(injectcmd, result);
 						}
-						ui_print("TWRP injection complete.\n");
+						gui_print("TWRP injection complete.\n");
 					}
 				}
 			}
@@ -1155,11 +1155,17 @@
 		if (function == "adbsideloadcancel")
 		{
 			int child_pid;
+			char child_prop[PROPERTY_VALUE_MAX];
 			string Sideload_File;
 			Sideload_File = DataManager::GetCurrentStoragePath() + "/sideload.zip";
 			unlink(Sideload_File.c_str());
-			DataManager::GetValue("tw_child_pid", child_pid);
-			ui_print("Cancelling ADB sideload...\n");
+			property_get("tw_child_pid", child_prop, "error");
+			if (strcmp(child_prop, "error") == 0) {
+				LOGERR("Unable to get child ID from prop\n");
+				return 0;
+			}
+			child_pid = atoi(child_prop);
+			gui_print("Cancelling ADB sideload...\n");
 			kill(child_pid, SIGTERM);
 			DataManager::SetValue("tw_page_done", "1"); // For OpenRecoveryScript support
 			return 0;
@@ -1174,14 +1180,14 @@
 				// Run those first.
 				int reboot = 0;
 				if (TWFunc::Path_Exists(SCRIPT_FILE_TMP)) {
-					ui_print("Processing AOSP recovery commands...\n");
+					gui_print("Processing AOSP recovery commands...\n");
 					if (OpenRecoveryScript::run_script_file() == 0) {
 						reboot = 1;
 					}
 				}
 				// Check for the ORS file in /cache and attempt to run those commands.
 				if (OpenRecoveryScript::check_for_script_file()) {
-					ui_print("Processing OpenRecoveryScript file...\n");
+					gui_print("Processing OpenRecoveryScript file...\n");
 					if (OpenRecoveryScript::run_script_file() == 0) {
 						reboot = 1;
 					}
@@ -1263,7 +1269,7 @@
 	DataManager::GetValue("tw_terminal_command_thread", command);
 	fp = popen(command.c_str(), "r");
 	if (fp == NULL) {
-		LOGE("Error opening command to run.\n");
+		LOGERR("Error opening command to run.\n");
 	} else {
 		int fd = fileno(fp), has_data = 0, check = 0, keep_going = -1, bytes_read = 0;
 		struct timeval timeout;
@@ -1290,7 +1296,7 @@
 				memset(line, 0, sizeof(line));
 				bytes_read = read(fd, line, sizeof(line));
 				if (bytes_read > 0)
-					ui_print("%s", line); // Display output
+					gui_print("%s", line); // Display output
 				else
 					keep_going = 0; // Done executing
 			}
diff --git a/gui/animation.cpp b/gui/animation.cpp
index 3021f46..77d7b54 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
diff --git a/gui/blanktimer.cpp b/gui/blanktimer.cpp
index 17cc0b3..700a9ad 100644
--- a/gui/blanktimer.cpp
+++ b/gui/blanktimer.cpp
@@ -39,8 +39,7 @@
 #include "blanktimer.hpp"
 #include "../data.hpp"
 extern "C" {
-#include "../common.h"
-#include "../recovery_ui.h"
+#include "../twcommon.h"
 }
 #include "../twrp-functions.hpp"
 #include "../variables.h"
@@ -140,7 +139,7 @@
 		case 3:
 #ifndef TW_NO_SCREEN_BLANK
 			if (gr_fb_blank(0) < 0) {
-				LOGI("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n");
+				LOGINFO("blanktimer::resetTimerAndUnblank failed to gr_fb_blank(0)\n");
 				break;
 			}
 #endif
diff --git a/gui/button.cpp b/gui/button.cpp
index 5ba8182..af7d07b 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -34,9 +34,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -87,7 +86,7 @@
 		}
 	}
 	if (!hasFill && mButtonImg == NULL) {
-		LOGE("No image resource or fill specified for button.\n");
+		LOGERR("No image resource or fill specified for button.\n");
 	}
 
     // The icon is a special case
diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp
index e52b589..077d5e2 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
diff --git a/gui/conditional.cpp b/gui/conditional.cpp
index 4e8a492..b3aba2d 100644
--- a/gui/conditional.cpp
+++ b/gui/conditional.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 #include "../variables.h"
 }
 
diff --git a/gui/console.cpp b/gui/console.cpp
index 7631e43..8a7a85e 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index d2be865..539bba0 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -38,10 +38,8 @@
 #include <algorithm>
 
 extern "C" {
-#include "../common.h"
-#include "../roots.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -945,7 +943,7 @@
 	d = opendir(folder.c_str());
 	if (d == NULL)
 	{
-		LOGI("Unable to open '%s'\n", folder.c_str());
+		LOGINFO("Unable to open '%s'\n", folder.c_str());
 		if (folder != "/" && (mShowNavFolders != 0 || mShowFiles != 0)) {
 			size_t found;
 			found = folder.find_last_of('/');
diff --git a/gui/fill.cpp b/gui/fill.cpp
index 11b700f..901eee1 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -36,7 +35,7 @@
 
     attr = node->first_attribute("color");
     if (!attr) {
-		LOGE("No color specified for fill\n");
+		LOGERR("No color specified for fill\n");
         return;
 	}
 
diff --git a/gui/gui.cpp b/gui/gui.cpp
index f08d68b..4c7bf5b 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -35,10 +35,8 @@
 
 extern "C"
 {
-#include "../common.h"
-#include "../roots.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 #include "../minzip/Zip.h"
 #include <pixelflinger/pixelflinger.h>
 }
@@ -217,7 +215,7 @@
 			  touch_repeat = 1;
 			  gettimeofday (&touchStart, NULL);
 #ifdef _EVENT_LOGGING
-			  LOGE ("TOUCH_HOLD: %d,%d\n", x, y);
+			  LOGERR("TOUCH_HOLD: %d,%d\n", x, y);
 #endif
 			  PageManager::NotifyTouch (TOUCH_HOLD, x, y);
                           blankTimer.resetTimerAndUnblank();
@@ -225,7 +223,7 @@
 		  else if (touch_repeat && mtime > 100)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGE ("TOUCH_REPEAT: %d,%d\n", x, y);
+			  LOGERR("TOUCH_REPEAT: %d,%d\n", x, y);
 #endif
 			  gettimeofday (&touchStart, NULL);
 			  PageManager::NotifyTouch (TOUCH_REPEAT, x, y);
@@ -234,7 +232,7 @@
 		  else if (key_repeat == 1 && mtime > 500)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGE ("KEY_HOLD: %d,%d\n", x, y);
+			  LOGERR("KEY_HOLD: %d,%d\n", x, y);
 #endif
 			  gettimeofday (&touchStart, NULL);
 			  key_repeat = 2;
@@ -244,7 +242,7 @@
 		  else if (key_repeat == 2 && mtime > 100)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGE ("KEY_REPEAT: %d,%d\n", x, y);
+			  LOGERR("KEY_REPEAT: %d,%d\n", x, y);
 #endif
 			  gettimeofday (&touchStart, NULL);
 			  kb.KeyRepeat ();
@@ -262,7 +260,7 @@
 			  if (state == 0)
 				{
 #ifdef _EVENT_LOGGING
-				  LOGE ("TOUCH_RELEASE: %d,%d\n", x, y);
+				  LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
 #endif
 				  PageManager::NotifyTouch (TOUCH_RELEASE, x, y);
 				  blankTimer.resetTimerAndUnblank();
@@ -279,7 +277,7 @@
 			  if (!drag)
 				{
 #ifdef _EVENT_LOGGING
-				  LOGE ("TOUCH_START: %d,%d\n", x, y);
+				  LOGERR("TOUCH_START: %d,%d\n", x, y);
 #endif
 				  if (PageManager::NotifyTouch (TOUCH_START, x, y) > 0)
 					state = 1;
@@ -295,7 +293,7 @@
 				  if (state == 0)
 					{
 #ifdef _EVENT_LOGGING
-					  LOGE ("TOUCH_DRAG: %d,%d\n", x, y);
+					  LOGERR("TOUCH_DRAG: %d,%d\n", x, y);
 #endif
 					  if (PageManager::NotifyTouch (TOUCH_DRAG, x, y) > 0)
 						state = 1;
@@ -309,7 +307,7 @@
 		{
 		  // Handle key-press here
 #ifdef _EVENT_LOGGING
-		  LOGE ("TOUCH_KEY: %d\n", ev.code);
+		  LOGERR("TOUCH_KEY: %d\n", ev.code);
 #endif
 		  if (ev.value != 0)
 			{
@@ -502,7 +500,7 @@
 int
 gui_changePage (std::string newPage)
 {
-  LOGI ("Set page: '%s'\n", newPage.c_str ());
+  LOGINFO("Set page: '%s'\n", newPage.c_str ());
   PageManager::ChangePage (newPage);
   pthread_mutex_lock(&gForceRendermutex);
   gForceRender = 1;
@@ -600,41 +598,41 @@
 	{
 	  if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "decrypt"))
 		{
-		  LOGE ("Failed to load base packages.\n");
+		  LOGERR("Failed to load base packages.\n");
 		  goto error;
 		}
 	  else
 		check = 1;
 	}
   if (check == 0
-	  && PageManager::LoadPackage ("TWRP", "/script/ui.xml", "main"))
+	  && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main"))
 	{
 	  std::string theme_path;
 
 	  theme_path = DataManager::GetSettingsStoragePath ();
-	  if (!PartitionManager.Mount_Settings_Storage (false))
+	  if (!PartitionManager.Mount_Settings_Storage(false))
 		{
 		  int retry_count = 5;
 		  while (retry_count > 0
-				 && !PartitionManager.Mount_Settings_Storage (false))
+				 && !PartitionManager.Mount_Settings_Storage(false))
 			{
 			  usleep (500000);
 			  retry_count--;
 			}
-		  if (!PartitionManager.Mount_Settings_Storage (false))
+		  if (!PartitionManager.Mount_Settings_Storage(false))
 			{
-			  LOGE ("Unable to mount %s during GUI startup.\n",
+			  LOGERR("Unable to mount %s during GUI startup.\n",
 					theme_path.c_str ());
 			  check = 1;
 			}
 		}
 
 	  theme_path += "/TWRP/theme/ui.zip";
-	  if (check || PageManager::LoadPackage ("TWRP", theme_path, "main"))
+	  if (check || PageManager::LoadPackage("TWRP", theme_path, "main"))
 		{
-		  if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "main"))
+		  if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
 			{
-			  LOGE ("Failed to load base packages.\n");
+			  LOGERR("Failed to load base packages.\n");
 			  goto error;
 			}
 		}
@@ -647,7 +645,7 @@
   return 0;
 
 error:
-  LOGE ("An internal error has occurred.\n");
+  LOGERR("An internal error has occurred.\n");
   gGuiInitialized = 0;
   return -1;
 }
@@ -687,7 +685,7 @@
 	loopTimer ();
 
   // Set the default package
-  PageManager::SelectPackage ("TWRP");
+  PageManager::SelectPackage("TWRP");
 
   if (!gGuiInputRunning)
 	{
@@ -697,7 +695,7 @@
 	  gGuiInputRunning = 1;
 	}
 
-  DataManager::SetValue ("tw_page_done", 0);
+  DataManager::SetValue("tw_page_done", 0);
   return runPage (page_name);
 }
 
@@ -722,7 +720,7 @@
 			flip ();
 
 		  if (ret < 0)
-			LOGE ("An update request has failed.\n");
+			LOGERR("An update request has failed.\n");
 		}
 	  else
 		{
diff --git a/gui/hardwarekeyboard.cpp b/gui/hardwarekeyboard.cpp
index 39b02cc..96958d5 100644
--- a/gui/hardwarekeyboard.cpp
+++ b/gui/hardwarekeyboard.cpp
@@ -19,9 +19,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -37,7 +36,7 @@
 
 int HardwareKeyboard::KeyDown(int key_code) {
 #ifdef _EVENT_LOGGING
-	LOGE("HardwareKeyboard::KeyDown %i\n", key_code);
+	LOGERR("HardwareKeyboard::KeyDown %i\n", key_code);
 #endif
 	PageManager::NotifyKey(key_code);
 	return 0; // 0 = no key repeat anything else turns on key repeat
@@ -45,14 +44,14 @@
 
 int HardwareKeyboard::KeyUp(int key_code) {
 #ifdef _EVENT_LOGGING
-	LOGE("HardwareKeyboard::KeyUp %i\n", key_code);
+	LOGERR("HardwareKeyboard::KeyUp %i\n", key_code);
 #endif
 	return 0;
 }
 
 int HardwareKeyboard::KeyRepeat(void) {
 #ifdef _EVENT_LOGGING
-	LOGE("HardwareKeyboard::KeyRepeat\n");
+	LOGERR("HardwareKeyboard::KeyRepeat\n");
 #endif
 	return 0;
 }
diff --git a/gui/image.cpp b/gui/image.cpp
index 05e5178..c684d1b 100644
--- a/gui/image.cpp
+++ b/gui/image.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
diff --git a/gui/input.cpp b/gui/input.cpp
index 2418c4c..e016724 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -20,9 +20,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -300,7 +299,7 @@
 				}
 			}
 		} else
-			LOGI("GUIInput::HandleTextLocation -> We really shouldn't ever get here...\n");
+			LOGINFO("GUIInput::HandleTextLocation -> We really shouldn't ever get here...\n");
 	} else if (x > lastX) {
 		// Dragging to right, scrolling left
 		while (-1) {
diff --git a/gui/keyboard.cpp b/gui/keyboard.cpp
index b74ff56..7b6d006 100644
--- a/gui/keyboard.cpp
+++ b/gui/keyboard.cpp
@@ -38,9 +38,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -116,7 +115,7 @@
 	while (keylayout)
 	{
 		if (layoutindex > MAX_KEYBOARD_LAYOUTS) {
-			LOGE("Too many layouts defined in keyboard.\n");
+			LOGERR("Too many layouts defined in keyboard.\n");
 			return;
 		}
 
@@ -141,7 +140,7 @@
 		while (keyrow)
 		{
 			if (rowindex > MAX_KEYBOARD_ROWS) {
-				LOGE("Too many rows defined in keyboard.\n");
+				LOGERR("Too many rows defined in keyboard.\n");
 				return;
 			}
 
@@ -158,20 +157,20 @@
 				char keyinfo[255];
 
 				if (keyindex > MAX_KEYBOARD_KEYS) {
-					LOGE("Too many keys defined in a keyboard row.\n");
+					LOGERR("Too many keys defined in a keyboard row.\n");
 					return;
 				}
 
 				stratt = attr->value();
 				if (strlen(stratt.c_str()) >= 255) {
-					LOGE("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
+					LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
 					return;
 				}
 
 				strcpy(keyinfo, stratt.c_str());
 
 				if (strlen(keyinfo) == 0) {
-					LOGE("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
+					LOGERR("No key info on layout%i, row%i, key%dd.\n", layoutindex, rowindex, keyindex);
 					return;
 				}
 
@@ -220,7 +219,7 @@
 						// This is an action
 						keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].key = KEYBOARD_ACTION;
 					} else
-						LOGE("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
+						LOGERR("Invalid key info on layout%i, row%i, key%02i.\n", layoutindex, rowindex, keyindex);
 				}
 
 				// PROCESS LONG PRESS INFO IF EXISTS
@@ -229,14 +228,14 @@
 				if (attr) {
 					stratt = attr->value();
 					if (strlen(stratt.c_str()) >= 255) {
-						LOGE("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
+						LOGERR("Key info on layout%i, row%i, key%dd is too long.\n", layoutindex, rowindex, keyindex);
 						return;
 					}
 
 					strcpy(keyinfo, stratt.c_str());
 
 					if (strlen(keyinfo) == 0) {
-						LOGE("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
+						LOGERR("No long press info on layout%i, row%i, long%dd.\n", layoutindex, rowindex, keyindex);
 						return;
 					}
 
@@ -282,7 +281,7 @@
 							// This is an action
 							keyboard_keys[layoutindex - 1][rowindex - 1][keyindex - 1].longpresskey = KEYBOARD_ACTION;
 						} else
-							LOGE("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
+							LOGERR("Invalid long press key info on layout%i, row%i, long%02i.\n", layoutindex, rowindex, keyindex);
 					}
 				}
 				keyindex++;
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 910a6a3..3af40ed 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -38,10 +38,8 @@
 #include <algorithm>
 
 extern "C" {
-#include "../common.h"
-#include "../roots.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 40de44f..bf44b38 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -35,9 +35,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -171,11 +170,11 @@
         mName = page->first_attribute("name")->value();
     else
     {
-        LOGE("No page name attribute found!\n");
+        LOGERR("No page name attribute found!\n");
         return;
     }
 
-    LOGI("Loading page %s\n", mName.c_str());
+    LOGINFO("Loading page %s\n", mName.c_str());
 
     // This is a recursive routine for template handling
     ProcessNode(page, templates);
@@ -187,7 +186,7 @@
 {
     if (depth == 10)
     {
-        LOGE("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
+        LOGERR("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
         return false;
     }
 
@@ -303,7 +302,7 @@
         {
             if (!templates || !child->first_attribute("name"))
             {
-                LOGE("Invalid template request.\n");
+                LOGERR("Invalid template request.\n");
             }
             else
             {
@@ -331,7 +330,7 @@
         }
         else
         {
-            LOGE("Unknown object type.\n");
+            LOGERR("Unknown object type.\n");
         }
         child = child->next_sibling("object");
     }
@@ -349,7 +348,7 @@
     for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
     {
         if ((*iter)->Render())
-            LOGE("A render request has failed.\n");
+            LOGERR("A render request has failed.\n");
     }
     return 0;
 }
@@ -363,7 +362,7 @@
     {
         int ret = (*iter)->Update();
         if (ret < 0)
-            LOGE("An update request has failed.\n");
+            LOGERR("An update request has failed.\n");
         else if (ret > retCode)
             retCode = ret;
     }
@@ -421,7 +420,7 @@
         if (ret == 0)
             return 0;
         else if (ret < 0)
-            LOGE("An action handler has returned an error");
+            LOGERR("An action handler has returned an error");
     }
     return 1;
 }
@@ -440,7 +439,7 @@
         if (ret == 0)
             return 0;
         else if (ret < 0)
-            LOGE("A keyboard handler has returned an error");
+            LOGERR("A keyboard handler has returned an error");
     }
     return 1;
 }
@@ -459,7 +458,7 @@
         if (ret == 0)
             return 0;
         else if (ret < 0)
-            LOGE("An input focus handler has returned an error");
+            LOGERR("An input focus handler has returned an error");
     }
     return 1;
 }
@@ -485,7 +484,7 @@
     for (iter = mActions.begin(); iter != mActions.end(); ++iter)
     {
         if ((*iter)->NotifyVarChange(varName, value))
-            LOGE("An action handler errored on NotifyVarChange.\n");
+            LOGERR("An action handler errored on NotifyVarChange.\n");
     }
     return 0;
 }
@@ -520,17 +519,17 @@
         parent = mDoc.first_node("install");
 
     // Now, let's parse the XML
-    LOGI("Loading resources...\n");
+    LOGINFO("Loading resources...\n");
     child = parent->first_node("resources");
     if (child)
         mResources = new ResourceManager(child, package);
 
-    LOGI("Loading variables...\n");
+    LOGINFO("Loading variables...\n");
     child = parent->first_node("variables");
     if (child)
         LoadVariables(child);
 
-    LOGI("Loading pages...\n");
+    LOGINFO("Loading pages...\n");
     // This may be NULL if no templates are present
     templates = parent->first_node("templates");
 
@@ -554,7 +553,7 @@
     }
     else
     {
-        LOGE("Unable to locate page (%s)\n", page.c_str());
+        LOGERR("Unable to locate page (%s)\n", page.c_str());
     }
     return -1;
 }
@@ -618,7 +617,7 @@
         Page* page = new Page(child, templates);
         if (page->GetName().empty())
         {
-            LOGE("Unable to process load page\n");
+            LOGERR("Unable to process load page\n");
             delete page;
         }
         else
@@ -697,7 +696,7 @@
     int ret;
 
     // Open the XML file
-    LOGI("Loading package: %s (%s)\n", name.c_str(), package.c_str());
+    LOGINFO("Loading package: %s (%s)\n", name.c_str(), package.c_str());
     if (mzOpenZipArchive(package.c_str(), &zip))
     {
         // We can try to load the XML directly...
@@ -721,7 +720,7 @@
         const ZipEntry* ui_xml = mzFindZipEntry(&zip, "ui.xml");
         if (ui_xml == NULL)
         {
-            LOGE("Unable to locate ui.xml in zip file\n");
+            LOGERR("Unable to locate ui.xml in zip file\n");
             goto error;
         }
     
@@ -732,7 +731,7 @@
     
         if (!mzExtractZipEntryToBuffer(&zip, ui_xml, (unsigned char*) xmlFile))
         {
-            LOGE("Unable to extract ui.xml\n");
+            LOGERR("Unable to extract ui.xml\n");
             goto error;
         }
     }
@@ -752,7 +751,7 @@
     }
     else
     {
-        LOGE("Package %s failed to load.\n", name.c_str());
+        LOGERR("Package %s failed to load.\n", name.c_str());
     }
 	
     // The first successful package we loaded is the base
@@ -765,7 +764,7 @@
     return ret;
 
 error:
-    LOGE("An internal error has occurred.\n");
+    LOGERR("An internal error has occurred.\n");
     if (pZip)       mzCloseZipArchive(pZip);
     if (xmlFile)    free(xmlFile);
     return -1;
@@ -780,20 +779,20 @@
     {
         return (*iter).second;
     }
-    LOGE("Unable to locate package %s\n", name.c_str());
+    LOGERR("Unable to locate package %s\n", name.c_str());
     return NULL;
 }
 
 PageSet* PageManager::SelectPackage(std::string name)
 {
-    LOGI("Switching packages (%s)\n", name.c_str());
+    LOGINFO("Switching packages (%s)\n", name.c_str());
     PageSet* tmp;
 
     tmp = FindPackage(name);
     if (tmp)
         mCurrentSet = tmp;
     else
-        LOGE("Unable to find package.\n");
+        LOGERR("Unable to find package.\n");
 
     return mCurrentSet;
 }
@@ -811,7 +810,7 @@
 
     if (LoadPackage(name, package, "main") != 0)
     {
-        LOGE("Failed to load package.\n");
+        LOGERR("Failed to load package.\n");
         mPageSets.insert(std::pair<std::string, PageSet*>(name, set));
         return -1;
     }
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index 9f9321c..36d5c16 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -38,10 +38,8 @@
 #include <algorithm>
 
 extern "C" {
-#include "../common.h"
-#include "../roots.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -330,12 +328,12 @@
 			PartitionManager.Get_Partition_List(ListType, &mList);
 		} else {
 			mList.clear();
-			LOGE("No partition listtype name specified for partitionlist GUI element\n");
+			LOGERR("No partition listtype name specified for partitionlist GUI element\n");
 			return;
 		}
 	} else {
 		mList.clear();
-		LOGE("No partition listtype specified for partitionlist GUI element\n");
+		LOGERR("No partition listtype specified for partitionlist GUI element\n");
 		return;
 	}
 }
@@ -755,7 +753,7 @@
 					bool update_size = false;
 					TWPartition* Part = PartitionManager.Find_Partition_By_Path(str);
 					if (Part == NULL) {
-						LOGE("Unable to locate partition for '%s'\n", str.c_str());
+						LOGERR("Unable to locate partition for '%s'\n", str.c_str());
 						return 0;
 					}
 					if (!Part->Is_Mounted() && Part->Removable)
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index e0e9c51..dce4315 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -39,7 +38,7 @@
 
     if (!node)
     {
-        LOGE("GUIProgressBar created without XML node\n");
+        LOGERR("GUIProgressBar created without XML node\n");
         return;
     }
 
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 2f2ea95..aaa1533 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -21,9 +21,8 @@
 #include <iomanip>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -207,9 +206,9 @@
 
 				if (!attr_name) {
 					std::string res_name = attr_name->value();
-					LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
 				} else
-					LOGE("Resource type (%s) failed to load\n", type.c_str());
+					LOGERR("Resource type (%s) failed to load\n", type.c_str());
 
                 delete res;
             }
@@ -227,9 +226,9 @@
 
 				if (!attr_name) {
 					std::string res_name = attr_name->value();
-					LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
 				} else
-					LOGE("Resource type (%s) failed to load\n", type.c_str());
+					LOGERR("Resource type (%s) failed to load\n", type.c_str());
 
                 delete res;
             }
@@ -247,9 +246,9 @@
 
 				if (!attr_name) {
 					std::string res_name = attr_name->value();
-					LOGE("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
 				} else
-					LOGE("Resource type (%s) failed to load\n", type.c_str());
+					LOGERR("Resource type (%s) failed to load\n", type.c_str());
 
                 delete res;
             }
@@ -260,7 +259,7 @@
         }
         else
         {
-            LOGE("Resource type (%s) not supported.\n", type.c_str());
+            LOGERR("Resource type (%s) not supported.\n", type.c_str());
         }
 
         child = child->next_sibling("resource");
diff --git a/gui/slider.cpp b/gui/slider.cpp
index 95962c0..4542d60 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -19,9 +19,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"
@@ -40,7 +39,7 @@
 
     if (!node)
     {
-        LOGE("GUISlider created without XML node\n");
+        LOGERR("GUISlider created without XML node\n");
         return;
     }
 
@@ -74,7 +73,7 @@
         sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow)
     }
 
-    //LOGI("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
+    //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
 	mActionX = mRenderX;
     mActionY = mRenderY;
     mActionW = mRenderW;
diff --git a/gui/text.cpp b/gui/text.cpp
index 1eceab1..46a6622 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -18,9 +18,8 @@
 #include <string>
 
 extern "C" {
-#include "../common.h"
+#include "../twcommon.h"
 #include "../minuitwrp/minui.h"
-#include "../recovery_ui.h"
 }
 
 #include "rapidxml.hpp"