Unify indentation and little clean-up in TWRP files

Signed-off-by: Vojtech Bocek <vbocek@gmail.com>
diff --git a/data.cpp b/data.cpp
index 65f706e..c028897 100644
--- a/data.cpp
+++ b/data.cpp
@@ -43,26 +43,26 @@
 #include "gui/blanktimer.hpp"
 
 #ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
-    #include "cutils/properties.h"
+	#include "cutils/properties.h"
 #endif
 
 extern "C"
 {
-    #include "twcommon.h"
-    #include "data.h"
+	#include "twcommon.h"
+	#include "data.h"
 	#include "gui/pages.h"
 
 	void gui_notifyVarChange(const char *name, const char* value);
 }
 
-#define FILE_VERSION    0x00010001
+#define FILE_VERSION 0x00010001
 
 using namespace std;
 
-map<string, DataManager::TStrIntPair>   DataManager::mValues;
-map<string, string>                     DataManager::mConstValues;
-string                                  DataManager::mBackingFile;
-int                                     DataManager::mInitialized = 0;
+map<string, DataManager::TStrIntPair>	DataManager::mValues;
+map<string, string>					 	DataManager::mConstValues;
+string									DataManager::mBackingFile;
+int										DataManager::mInitialized = 0;
 extern blanktimer blankTimer;
 
 // Device ID functions
@@ -81,12 +81,12 @@
 	return;
 }
 
-#define CMDLINE_SERIALNO        "androidboot.serialno="
-#define CMDLINE_SERIALNO_LEN    (strlen(CMDLINE_SERIALNO))
-#define CPUINFO_SERIALNO        "Serial"
-#define CPUINFO_SERIALNO_LEN    (strlen(CPUINFO_SERIALNO))
-#define CPUINFO_HARDWARE        "Hardware"
-#define CPUINFO_HARDWARE_LEN    (strlen(CPUINFO_HARDWARE))
+#define CMDLINE_SERIALNO		"androidboot.serialno="
+#define CMDLINE_SERIALNO_LEN	(strlen(CMDLINE_SERIALNO))
+#define CPUINFO_SERIALNO		"Serial"
+#define CPUINFO_SERIALNO_LEN	(strlen(CPUINFO_SERIALNO))
+#define CPUINFO_HARDWARE		"Hardware"
+#define CPUINFO_HARDWARE_LEN	(strlen(CPUINFO_HARDWARE))
 
 void DataManager::get_device_id(void) {
 	FILE *fp;
@@ -94,8 +94,8 @@
 	char hardware_id[32], device_id[64];
 	char* token;
 
-    // Assign a blank device_id to start with
-    device_id[0] = 0;
+	// Assign a blank device_id to start with
+	device_id[0] = 0;
 
 #ifdef TW_USE_MODEL_HARDWARE_ID_FOR_DEVICE_ID
 	// Now we'll use product_model_hardwareid as device id
@@ -121,37 +121,37 @@
 #endif
 
 #ifndef TW_FORCE_CPUINFO_FOR_DEVICE_ID
-    // First, try the cmdline to see if the serial number was supplied
+	// First, try the cmdline to see if the serial number was supplied
 	fp = fopen("/proc/cmdline", "rt");
 	if (fp != NULL)
-    {
-        // First step, read the line. For cmdline, it's one long line
-        fgets(line, sizeof(line), fp);
-        fclose(fp);
+	{
+		// First step, read the line. For cmdline, it's one long line
+		fgets(line, sizeof(line), fp);
+		fclose(fp);
 
-        // Now, let's tokenize the string
-        token = strtok(line, " ");
+		// Now, let's tokenize the string
+		token = strtok(line, " ");
 
-        // Let's walk through the line, looking for the CMDLINE_SERIALNO token
-        while (token)
-        {
-            // We don't need to verify the length of token, because if it's too short, it will mismatch CMDLINE_SERIALNO at the NULL
-            if (memcmp(token, CMDLINE_SERIALNO, CMDLINE_SERIALNO_LEN) == 0)
-            {
-                // We found the serial number!
-                strcpy(device_id, token + CMDLINE_SERIALNO_LEN);
+		// Let's walk through the line, looking for the CMDLINE_SERIALNO token
+		while (token)
+		{
+			// We don't need to verify the length of token, because if it's too short, it will mismatch CMDLINE_SERIALNO at the NULL
+			if (memcmp(token, CMDLINE_SERIALNO, CMDLINE_SERIALNO_LEN) == 0)
+			{
+				// We found the serial number!
+				strcpy(device_id, token + CMDLINE_SERIALNO_LEN);
 				sanitize_device_id((char *)device_id);
 				mConstValues.insert(make_pair("device_id", device_id));
-                return;
-            }
-            token = strtok(NULL, " ");
-        }
-    }
+				return;
+			}
+			token = strtok(NULL, " ");
+		}
+	}
 #endif
 	// Now we'll try cpuinfo for a serial number
 	fp = fopen("/proc/cpuinfo", "rt");
 	if (fp != NULL)
-    {
+	{
 		while (fgets(line, sizeof(line), fp) != NULL) { // First step, read the line.
 			if (memcmp(line, CPUINFO_SERIALNO, CPUINFO_SERIALNO_LEN) == 0)  // check the beginning of the line for "Serial"
 			{
@@ -159,7 +159,7 @@
 				token = line + CPUINFO_SERIALNO_LEN; // skip past "Serial"
 				while ((*token > 0 && *token <= 32 ) || *token == ':') token++; // skip over all spaces and the colon
 				if (*token != 0) {
-                    token[30] = 0;
+					token[30] = 0;
 					if (token[strlen(token)-1] == 10) { // checking for endline chars and dropping them from the end of the string if needed
 						memset(device_id, 0, sizeof(device_id));
 						strncpy(device_id, token, strlen(token) - 1);
@@ -177,9 +177,9 @@
 				token = line + CPUINFO_HARDWARE_LEN; // skip past "Hardware"
 				while ((*token > 0 && *token <= 32 ) || *token == ':')  token++; // skip over all spaces and the colon
 				if (*token != 0) {
-                    token[30] = 0;
+					token[30] = 0;
 					if (token[strlen(token)-1] == 10) { // checking for endline chars and dropping them from the end of the string if needed
-                        memset(hardware_id, 0, sizeof(hardware_id));
+						memset(hardware_id, 0, sizeof(hardware_id));
 						strncpy(hardware_id, token, strlen(token) - 1);
 					} else {
 						strcpy(hardware_id, token);
@@ -189,7 +189,7 @@
 			}
 		}
 		fclose(fp);
-    }
+	}
 
 	if (hardware_id[0] != 0) {
 		LOGINFO("\nusing hardware id for device id: '%s'\n", hardware_id);
@@ -199,76 +199,76 @@
 		return;
 	}
 
-    strcpy(device_id, "serialno");
+	strcpy(device_id, "serialno");
 	LOGERR("=> device id not found, using '%s'.", device_id);
 	mConstValues.insert(make_pair("device_id", device_id));
-    return;
+	return;
 }
 
 int DataManager::ResetDefaults()
 {
-    mValues.clear();
-    mConstValues.clear();
-    SetDefaultValues();
-    return 0;
+	mValues.clear();
+	mConstValues.clear();
+	SetDefaultValues();
+	return 0;
 }
 
 int DataManager::LoadValues(const string filename)
 {
-    string str, dev_id;
+	string str, dev_id;
 
 	if (!mInitialized)
-        SetDefaultValues();
+		SetDefaultValues();
 
-    GetValue("device_id", dev_id);
+	GetValue("device_id", dev_id);
 	// Save off the backing file for set operations
-    mBackingFile = filename;
+	mBackingFile = filename;
 
-    // Read in the file, if possible
-    FILE* in = fopen(filename.c_str(), "rb");
-    if (!in) {
+	// Read in the file, if possible
+	FILE* in = fopen(filename.c_str(), "rb");
+	if (!in) {
 		LOGINFO("Settings file '%s' not found.\n", filename.c_str());
 		return 0;
 	} else {
 		LOGINFO("Loading settings from '%s'.\n", filename.c_str());
 	}
 
-    int file_version;
-    if (fread(&file_version, 1, sizeof(int), in) != sizeof(int))    goto error;
-    if (file_version != FILE_VERSION)                               goto error;
+	int file_version;
+	if (fread(&file_version, 1, sizeof(int), in) != sizeof(int))	goto error;
+	if (file_version != FILE_VERSION)								goto error;
 
-    while (!feof(in))
-    {
-        string Name;
-        string Value;
-        unsigned short length;
-        char array[512];
+	while (!feof(in))
+	{
+		string Name;
+		string Value;
+		unsigned short length;
+		char array[512];
 
-        if (fread(&length, 1, sizeof(unsigned short), in) != sizeof(unsigned short))    goto error;
-        if (length >= 512)                                                              goto error;
-        if (fread(array, 1, length, in) != length)                                      goto error;
-        Name = array;
+		if (fread(&length, 1, sizeof(unsigned short), in) != sizeof(unsigned short))	goto error;
+		if (length >= 512)																goto error;
+		if (fread(array, 1, length, in) != length)										goto error;
+		Name = array;
 
-        if (fread(&length, 1, sizeof(unsigned short), in) != sizeof(unsigned short))    goto error;
-        if (length >= 512)                                                              goto error;
-        if (fread(array, 1, length, in) != length)                                      goto error;
-        Value = array;
+		if (fread(&length, 1, sizeof(unsigned short), in) != sizeof(unsigned short))	goto error;
+		if (length >= 512)																goto error;
+		if (fread(array, 1, length, in) != length)										goto error;
+		Value = array;
 
-        map<string, TStrIntPair>::iterator pos;
+		map<string, TStrIntPair>::iterator pos;
 
-        pos = mValues.find(Name);
-        if (pos != mValues.end())
-        {
-            pos->second.first = Value;
-            pos->second.second = 1;
-        }
-        else
-            mValues.insert(TNameValuePair(Name, TStrIntPair(Value, 1)));
+		pos = mValues.find(Name);
+		if (pos != mValues.end())
+		{
+			pos->second.first = Value;
+			pos->second.second = 1;
+		}
+		else
+			mValues.insert(TNameValuePair(Name, TStrIntPair(Value, 1)));
 		if (Name == "tw_screen_timeout_secs")
 			blankTimer.setTime(atoi(Value.c_str()));
-    }
+	}
 error:
-    fclose(in);
+	fclose(in);
 	string current = GetCurrentStoragePath();
 	string settings = GetSettingsStoragePath();
 	if (current != settings && !PartitionManager.Mount_By_Path(current, false)) {
@@ -276,185 +276,188 @@
 	} else {
 		SetBackupFolder();
 	}
-    return 0;
+	return 0;
 }
 
 int DataManager::Flush()
 {
-    return SaveValues();
+	return SaveValues();
 }
 
 int DataManager::SaveValues()
 {
-    if (mBackingFile.empty())       return -1;
+	if (mBackingFile.empty())
+		return -1;
 
 	string mount_path = GetSettingsStoragePath();
 	PartitionManager.Mount_By_Path(mount_path.c_str(), 1);
 
 	FILE* out = fopen(mBackingFile.c_str(), "wb");
-    if (!out)                       return -1;
+	if (!out)
+		return -1;
 
-    int file_version = FILE_VERSION;
-    fwrite(&file_version, 1, sizeof(int), out);
+	int file_version = FILE_VERSION;
+	fwrite(&file_version, 1, sizeof(int), out);
 
-    map<string, TStrIntPair>::iterator iter;
-    for (iter = mValues.begin(); iter != mValues.end(); ++iter)
-    {
-        // Save only the persisted data
-        if (iter->second.second != 0)
-        {
-            unsigned short length = (unsigned short) iter->first.length() + 1;
-            fwrite(&length, 1, sizeof(unsigned short), out);
-            fwrite(iter->first.c_str(), 1, length, out);
-            length = (unsigned short) iter->second.first.length() + 1;
-            fwrite(&length, 1, sizeof(unsigned short), out);
-            fwrite(iter->second.first.c_str(), 1, length, out);
-        }
-    }
-    fclose(out);
-    return 0;
+	map<string, TStrIntPair>::iterator iter;
+	for (iter = mValues.begin(); iter != mValues.end(); ++iter)
+	{
+		// Save only the persisted data
+		if (iter->second.second != 0)
+		{
+			unsigned short length = (unsigned short) iter->first.length() + 1;
+			fwrite(&length, 1, sizeof(unsigned short), out);
+			fwrite(iter->first.c_str(), 1, length, out);
+			length = (unsigned short) iter->second.first.length() + 1;
+			fwrite(&length, 1, sizeof(unsigned short), out);
+			fwrite(iter->second.first.c_str(), 1, length, out);
+		}
+	}
+	fclose(out);
+	return 0;
 }
 
 int DataManager::GetValue(const string varName, string& value)
 {
-    string localStr = varName;
+	string localStr = varName;
 
-    if (!mInitialized)
-        SetDefaultValues();
+	if (!mInitialized)
+		SetDefaultValues();
 
-    // Strip off leading and trailing '%' if provided
-    if (localStr.length() > 2 && localStr[0] == '%' && localStr[localStr.length()-1] == '%')
-    {
-        localStr.erase(0, 1);
-        localStr.erase(localStr.length() - 1, 1);
-    }
+	// Strip off leading and trailing '%' if provided
+	if (localStr.length() > 2 && localStr[0] == '%' && localStr[localStr.length()-1] == '%')
+	{
+		localStr.erase(0, 1);
+		localStr.erase(localStr.length() - 1, 1);
+	}
 
-    // Handle magic values
-    if (GetMagicValue(localStr, value) == 0)     return 0;
+	// Handle magic values
+	if (GetMagicValue(localStr, value) == 0)
+		return 0;
 
-    map<string, string>::iterator constPos;
-    constPos = mConstValues.find(localStr);
-    if (constPos != mConstValues.end())
-    {
-        value = constPos->second;
-        return 0;
-    }
+	map<string, string>::iterator constPos;
+	constPos = mConstValues.find(localStr);
+	if (constPos != mConstValues.end())
+	{
+		value = constPos->second;
+		return 0;
+	}
 
-    map<string, TStrIntPair>::iterator pos;
-    pos = mValues.find(localStr);
-    if (pos == mValues.end())
-        return -1;
+	map<string, TStrIntPair>::iterator pos;
+	pos = mValues.find(localStr);
+	if (pos == mValues.end())
+		return -1;
 
-    value = pos->second.first;
-    return 0;
+	value = pos->second.first;
+	return 0;
 }
 
 int DataManager::GetValue(const string varName, int& value)
 {
-    string data;
+	string data;
 
-    if (GetValue(varName,data) != 0)
-        return -1;
+	if (GetValue(varName,data) != 0)
+		return -1;
 
-    value = atoi(data.c_str());
-    return 0;
+	value = atoi(data.c_str());
+	return 0;
 }
 
 int DataManager::GetValue(const string varName, float& value)
 {
-    string data;
+	string data;
 
-    if (GetValue(varName,data) != 0)
-        return -1;
+	if (GetValue(varName,data) != 0)
+		return -1;
 
-    value = atof(data.c_str());
-    return 0;
+	value = atof(data.c_str());
+	return 0;
 }
 
 unsigned long long DataManager::GetValue(const string varName, unsigned long long& value)
 {
-    string data;
+	string data;
 
-    if (GetValue(varName,data) != 0)
-        return -1;
+	if (GetValue(varName,data) != 0)
+		return -1;
 
-    value = strtoull(data.c_str(), NULL, 10);
-    return 0;
+	value = strtoull(data.c_str(), NULL, 10);
+	return 0;
 }
 
 // This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str
 string& DataManager::GetValueRef(const string varName)
 {
-    if (!mInitialized)
-        SetDefaultValues();
+	if (!mInitialized)
+		SetDefaultValues();
 
-    map<string, string>::iterator constPos;
-    constPos = mConstValues.find(varName);
-    if (constPos != mConstValues.end())
-        return constPos->second;
+	map<string, string>::iterator constPos;
+	constPos = mConstValues.find(varName);
+	if (constPos != mConstValues.end())
+		return constPos->second;
 
-    map<string, TStrIntPair>::iterator pos;
-    pos = mValues.find(varName);
-    if (pos == mValues.end())
-        pos = (mValues.insert(TNameValuePair(varName, TStrIntPair("", 0)))).first;
+	map<string, TStrIntPair>::iterator pos;
+	pos = mValues.find(varName);
+	if (pos == mValues.end())
+		pos = (mValues.insert(TNameValuePair(varName, TStrIntPair("", 0)))).first;
 
-    return pos->second.first;
+	return pos->second.first;
 }
 
 // This function will return an empty string if the value doesn't exist
 string DataManager::GetStrValue(const string varName)
 {
-    string retVal;
+	string retVal;
 
-    GetValue(varName, retVal);
-    return retVal;
+	GetValue(varName, retVal);
+	return retVal;
 }
 
 // This function will return 0 if the value doesn't exist
 int DataManager::GetIntValue(const string varName)
 {
-    string retVal;
+	string retVal;
 
-    GetValue(varName, retVal);
-    return atoi(retVal.c_str());
+	GetValue(varName, retVal);
+	return atoi(retVal.c_str());
 }
 
 int DataManager::SetValue(const string varName, string value, int persist /* = 0 */)
 {
-    if (!mInitialized)
-        SetDefaultValues();
+	if (!mInitialized)
+		SetDefaultValues();
 
-    // Don't allow empty values or numerical starting values
-    if (varName.empty() || (varName[0] >= '0' && varName[0] <= '9'))
-        return -1;
+	// Don't allow empty values or numerical starting values
+	if (varName.empty() || (varName[0] >= '0' && varName[0] <= '9'))
+		return -1;
 
-    map<string, string>::iterator constChk;
-    constChk = mConstValues.find(varName);
-    if (constChk != mConstValues.end())
-        return -1;
+	map<string, string>::iterator constChk;
+	constChk = mConstValues.find(varName);
+	if (constChk != mConstValues.end())
+		return -1;
 
-    map<string, TStrIntPair>::iterator pos;
-    pos = mValues.find(varName);
-    if (pos == mValues.end())
-        pos = (mValues.insert(TNameValuePair(varName, TStrIntPair(value, persist)))).first;
-    else
-        pos->second.first = value;
+	map<string, TStrIntPair>::iterator pos;
+	pos = mValues.find(varName);
+	if (pos == mValues.end())
+		pos = (mValues.insert(TNameValuePair(varName, TStrIntPair(value, persist)))).first;
+	else
+		pos->second.first = value;
 
-    if (pos->second.second != 0)
-        SaveValues();
+	if (pos->second.second != 0)
+		SaveValues();
 	if (varName == "tw_screen_timeout_secs") {
 		blankTimer.setTime(atoi(value.c_str()));
 	} else if (varName == "tw_storage_path") {
 		SetBackupFolder();
 	}
 	gui_notifyVarChange(varName.c_str(), value.c_str());
-    return 0;
+	return 0;
 }
 
 int DataManager::SetValue(const string varName, int value, int persist /* = 0 */)
 {
 	ostringstream valStr;
-    valStr << value;
+	valStr << value;
 	if (varName == "tw_use_external_storage") {
 		string str;
 
@@ -471,28 +474,29 @@
 
 		SetValue("tw_storage_path", str);
 	}
-    return SetValue(varName, valStr.str(), persist);
+	return SetValue(varName, valStr.str(), persist);
 }
 
 int DataManager::SetValue(const string varName, float value, int persist /* = 0 */)
 {
 	ostringstream valStr;
-    valStr << value;
-    return SetValue(varName, valStr.str(), persist);;
+	valStr << value;
+	return SetValue(varName, valStr.str(), persist);;
 }
 
 int DataManager::SetValue(const string varName, unsigned long long value, int persist /* = 0 */)
 {
 	ostringstream valStr;
-    valStr << value;
-    return SetValue(varName, valStr.str(), persist);;
+	valStr << value;
+	return SetValue(varName, valStr.str(), persist);
 }
 
 int DataManager::SetProgress(float Fraction) {
 	return SetValue("ui_progress", (float) (Fraction * 100.0));
 }
 
-int DataManager::ShowProgress(float Portion, float Seconds) {
+int DataManager::ShowProgress(float Portion, float Seconds)
+{
 	float Starting_Portion;
 	GetValue("ui_progress_portion", Starting_Portion);
 	if (SetValue("ui_progress_portion", (float)(Portion * 100.0) + Starting_Portion) != 0)
@@ -504,17 +508,16 @@
 
 void DataManager::DumpValues()
 {
-    map<string, TStrIntPair>::iterator iter;
-    gui_print("Data Manager dump - Values with leading X are persisted.\n");
-    for (iter = mValues.begin(); iter != mValues.end(); ++iter)
-    {
-        gui_print("%c %s=%s\n", iter->second.second ? 'X' : ' ', iter->first.c_str(), iter->second.first.c_str());
-    }
+	map<string, TStrIntPair>::iterator iter;
+	gui_print("Data Manager dump - Values with leading X are persisted.\n");
+	for (iter = mValues.begin(); iter != mValues.end(); ++iter)
+		gui_print("%c %s=%s\n", iter->second.second ? 'X' : ' ', iter->first.c_str(), iter->second.first.c_str());
 }
 
-void DataManager::update_tz_environment_variables(void) {
+void DataManager::update_tz_environment_variables(void)
+{
 	setenv("TZ", DataManager_GetStrValue(TW_TIME_ZONE_VAR), 1);
-    tzset();
+	tzset();
 }
 
 void DataManager::SetBackupFolder()
@@ -526,7 +529,7 @@
 	string dev_id;
 	GetValue("device_id", dev_id);
 
-    str += dev_id;
+	str += dev_id;
 	LOGINFO("Backup folder set to '%s'\n", str.c_str());
 	SetValue(TW_BACKUPS_FOLDER_VAR, str, 0);
 	if (partition != NULL) {
@@ -558,16 +561,16 @@
 
 void DataManager::SetDefaultValues()
 {
-    string str, path;
+	string str, path;
 
-    get_device_id();
+	get_device_id();
 
-    mInitialized = 1;
+	mInitialized = 1;
 
-    mConstValues.insert(make_pair("true", "1"));
-    mConstValues.insert(make_pair("false", "0"));
+	mConstValues.insert(make_pair("true", "1"));
+	mConstValues.insert(make_pair("false", "0"));
 
-    mConstValues.insert(make_pair(TW_VERSION_VAR, TW_VERSION_STR));
+	mConstValues.insert(make_pair(TW_VERSION_VAR, TW_VERSION_STR));
 	mValues.insert(make_pair("tw_storage_path", make_pair("/", 1)));
 
 #ifdef TW_FORCE_CPUINFO_FOR_DEVICE_ID
@@ -576,9 +579,9 @@
 
 #ifdef BOARD_HAS_NO_REAL_SDCARD
 	printf("BOARD_HAS_NO_REAL_SDCARD := true\n");
-    mConstValues.insert(make_pair(TW_ALLOW_PARTITION_SDCARD, "0"));
+	mConstValues.insert(make_pair(TW_ALLOW_PARTITION_SDCARD, "0"));
 #else
-    mConstValues.insert(make_pair(TW_ALLOW_PARTITION_SDCARD, "1"));
+	mConstValues.insert(make_pair(TW_ALLOW_PARTITION_SDCARD, "1"));
 #endif
 
 #ifdef TW_INCLUDE_DUMLOCK
@@ -720,45 +723,45 @@
 	string dev_id;
 	GetValue("device_id", dev_id);
 
-    str += dev_id;
+	str += dev_id;
 	SetValue(TW_BACKUPS_FOLDER_VAR, str, 0);
 
 #ifdef SP1_DISPLAY_NAME
 	printf("SP1_DISPLAY_NAME := %s\n", EXPAND(SP1_DISPLAY_NAME));
-    if (strlen(EXPAND(SP1_DISPLAY_NAME)))    mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_DISPLAY_NAME)));
+	if (strlen(EXPAND(SP1_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_DISPLAY_NAME)));
 #else
 	#ifdef SP1_NAME
 		printf("SP1_NAME := %s\n", EXPAND(SP1_NAME));
-		if (strlen(EXPAND(SP1_NAME)))    mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_NAME)));
+		if (strlen(EXPAND(SP1_NAME))) mConstValues.insert(make_pair(TW_SP1_PARTITION_NAME_VAR, EXPAND(SP1_NAME)));
 	#endif
 #endif
 #ifdef SP2_DISPLAY_NAME
 	printf("SP2_DISPLAY_NAME := %s\n", EXPAND(SP2_DISPLAY_NAME));
-    if (strlen(EXPAND(SP2_DISPLAY_NAME)))    mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_DISPLAY_NAME)));
+	if (strlen(EXPAND(SP2_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_DISPLAY_NAME)));
 #else
 	#ifdef SP2_NAME
 		printf("SP2_NAME := %s\n", EXPAND(SP2_NAME));
-		if (strlen(EXPAND(SP2_NAME)))    mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_NAME)));
+		if (strlen(EXPAND(SP2_NAME))) mConstValues.insert(make_pair(TW_SP2_PARTITION_NAME_VAR, EXPAND(SP2_NAME)));
 	#endif
 #endif
 #ifdef SP3_DISPLAY_NAME
 	printf("SP3_DISPLAY_NAME := %s\n", EXPAND(SP3_DISPLAY_NAME));
-    if (strlen(EXPAND(SP3_DISPLAY_NAME)))    mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_DISPLAY_NAME)));
+	if (strlen(EXPAND(SP3_DISPLAY_NAME))) mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_DISPLAY_NAME)));
 #else
 	#ifdef SP3_NAME
 		printf("SP3_NAME := %s\n", EXPAND(SP3_NAME));
-		if (strlen(EXPAND(SP3_NAME)))    mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_NAME)));
+		if (strlen(EXPAND(SP3_NAME))) mConstValues.insert(make_pair(TW_SP3_PARTITION_NAME_VAR, EXPAND(SP3_NAME)));
 	#endif
 #endif
 
-    mConstValues.insert(make_pair(TW_REBOOT_SYSTEM, "1"));
+	mConstValues.insert(make_pair(TW_REBOOT_SYSTEM, "1"));
 #ifdef TW_NO_REBOOT_RECOVERY
 	printf("TW_NO_REBOOT_RECOVERY := true\n");
 	mConstValues.insert(make_pair(TW_REBOOT_RECOVERY, "0"));
 #else
 	mConstValues.insert(make_pair(TW_REBOOT_RECOVERY, "1"));
 #endif
-    mConstValues.insert(make_pair(TW_REBOOT_POWEROFF, "1"));
+	mConstValues.insert(make_pair(TW_REBOOT_POWEROFF, "1"));
 #ifdef TW_NO_REBOOT_BOOTLOADER
 	printf("TW_NO_REBOOT_BOOTLOADER := true\n");
 	mConstValues.insert(make_pair(TW_REBOOT_BOOTLOADER, "0"));
@@ -843,15 +846,15 @@
 	mConstValues.insert(make_pair(TW_MIN_SYSTEM_VAR, TW_MIN_SYSTEM_SIZE));
 	mValues.insert(make_pair(TW_BACKUP_NAME, make_pair("(Current Date)", 0)));
 	mValues.insert(make_pair(TW_BACKUP_SYSTEM_VAR, make_pair("1", 1)));
-    mValues.insert(make_pair(TW_BACKUP_DATA_VAR, make_pair("1", 1)));
-    mValues.insert(make_pair(TW_BACKUP_BOOT_VAR, make_pair("1", 1)));
-    mValues.insert(make_pair(TW_BACKUP_RECOVERY_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_CACHE_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_SP1_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_SP2_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_SP3_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_ANDSEC_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_BACKUP_SDEXT_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_DATA_VAR, make_pair("1", 1)));
+	mValues.insert(make_pair(TW_BACKUP_BOOT_VAR, make_pair("1", 1)));
+	mValues.insert(make_pair(TW_BACKUP_RECOVERY_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_CACHE_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_SP1_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_SP2_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_SP3_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_ANDSEC_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_BACKUP_SDEXT_VAR, make_pair("0", 1)));
 	mValues.insert(make_pair(TW_BACKUP_SYSTEM_SIZE, make_pair("0", 0)));
 	mValues.insert(make_pair(TW_BACKUP_DATA_SIZE, make_pair("0", 0)));
 	mValues.insert(make_pair(TW_BACKUP_BOOT_SIZE, make_pair("0", 0)));
@@ -864,33 +867,33 @@
 	mValues.insert(make_pair(TW_BACKUP_SP3_SIZE, make_pair("0", 0)));
 	mValues.insert(make_pair(TW_STORAGE_FREE_SIZE, make_pair("0", 0)));
 
-    mValues.insert(make_pair(TW_REBOOT_AFTER_FLASH_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_SIGNED_ZIP_VERIFY_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_FORCE_MD5_CHECK_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_COLOR_THEME_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_USE_COMPRESSION_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_SHOW_SPAM_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_TIME_ZONE_VAR, make_pair("CST6CDT", 1)));
-    mValues.insert(make_pair(TW_SORT_FILES_BY_DATE_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_GUI_SORT_ORDER, make_pair("1", 1)));
-    mValues.insert(make_pair(TW_RM_RF_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_SKIP_MD5_CHECK_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_SKIP_MD5_GENERATE_VAR, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_SDEXT_SIZE, make_pair("512", 1)));
-    mValues.insert(make_pair(TW_SWAP_SIZE, make_pair("32", 1)));
-    mValues.insert(make_pair(TW_SDPART_FILE_SYSTEM, make_pair("ext3", 1)));
-    mValues.insert(make_pair(TW_TIME_ZONE_GUISEL, make_pair("CST6;CDT", 1)));
-    mValues.insert(make_pair(TW_TIME_ZONE_GUIOFFSET, make_pair("0", 1)));
-    mValues.insert(make_pair(TW_TIME_ZONE_GUIDST, make_pair("1", 1)));
-    mValues.insert(make_pair(TW_ACTION_BUSY, make_pair("0", 0)));
-    mValues.insert(make_pair(TW_BACKUP_AVG_IMG_RATE, make_pair("15000000", 1)));
-    mValues.insert(make_pair(TW_BACKUP_AVG_FILE_RATE, make_pair("3000000", 1)));
-    mValues.insert(make_pair(TW_BACKUP_AVG_FILE_COMP_RATE, make_pair("2000000", 1)));
-    mValues.insert(make_pair(TW_RESTORE_AVG_IMG_RATE, make_pair("15000000", 1)));
-    mValues.insert(make_pair(TW_RESTORE_AVG_FILE_RATE, make_pair("3000000", 1)));
-    mValues.insert(make_pair(TW_RESTORE_AVG_FILE_COMP_RATE, make_pair("2000000", 1)));
-    mValues.insert(make_pair("tw_wipe_cache", make_pair("0", 0)));
-    mValues.insert(make_pair("tw_wipe_dalvik", make_pair("0", 0)));
+	mValues.insert(make_pair(TW_REBOOT_AFTER_FLASH_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_SIGNED_ZIP_VERIFY_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_FORCE_MD5_CHECK_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_COLOR_THEME_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_USE_COMPRESSION_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_SHOW_SPAM_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_TIME_ZONE_VAR, make_pair("CST6CDT", 1)));
+	mValues.insert(make_pair(TW_SORT_FILES_BY_DATE_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_GUI_SORT_ORDER, make_pair("1", 1)));
+	mValues.insert(make_pair(TW_RM_RF_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_SKIP_MD5_CHECK_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_SKIP_MD5_GENERATE_VAR, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_SDEXT_SIZE, make_pair("512", 1)));
+	mValues.insert(make_pair(TW_SWAP_SIZE, make_pair("32", 1)));
+	mValues.insert(make_pair(TW_SDPART_FILE_SYSTEM, make_pair("ext3", 1)));
+	mValues.insert(make_pair(TW_TIME_ZONE_GUISEL, make_pair("CST6;CDT", 1)));
+	mValues.insert(make_pair(TW_TIME_ZONE_GUIOFFSET, make_pair("0", 1)));
+	mValues.insert(make_pair(TW_TIME_ZONE_GUIDST, make_pair("1", 1)));
+	mValues.insert(make_pair(TW_ACTION_BUSY, make_pair("0", 0)));
+	mValues.insert(make_pair(TW_BACKUP_AVG_IMG_RATE, make_pair("15000000", 1)));
+	mValues.insert(make_pair(TW_BACKUP_AVG_FILE_RATE, make_pair("3000000", 1)));
+	mValues.insert(make_pair(TW_BACKUP_AVG_FILE_COMP_RATE, make_pair("2000000", 1)));
+	mValues.insert(make_pair(TW_RESTORE_AVG_IMG_RATE, make_pair("15000000", 1)));
+	mValues.insert(make_pair(TW_RESTORE_AVG_FILE_RATE, make_pair("3000000", 1)));
+	mValues.insert(make_pair(TW_RESTORE_AVG_FILE_COMP_RATE, make_pair("2000000", 1)));
+	mValues.insert(make_pair("tw_wipe_cache", make_pair("0", 0)));
+	mValues.insert(make_pair("tw_wipe_dalvik", make_pair("0", 0)));
 	if (GetIntValue(TW_HAS_INTERNAL) == 1 && GetIntValue(TW_HAS_DATA_MEDIA) == 1 && GetIntValue(TW_HAS_EXTERNAL) == 0)
 		SetValue(TW_HAS_USB_STORAGE, 0, 0);
 	else
@@ -940,35 +943,37 @@
 // Magic Values
 int DataManager::GetMagicValue(const string varName, string& value)
 {
-    // Handle special dynamic cases
-    if (varName == "tw_time")
-    {
-        char tmp[32];
+	// Handle special dynamic cases
+	if (varName == "tw_time")
+	{
+		char tmp[32];
 
-        struct tm *current;
-        time_t now;
-	int tw_military_time;
-        now = time(0);
-        current = localtime(&now);
-	GetValue(TW_MILITARY_TIME, tw_military_time); 
-        if (current->tm_hour >= 12) {
-		if (tw_military_time == 1)
-            		sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
-		else
-            		sprintf(tmp, "%d:%02d PM", current->tm_hour == 12 ? 12 : current->tm_hour - 12, current->tm_min);
+		struct tm *current;
+		time_t now;
+		int tw_military_time;
+		now = time(0);
+		current = localtime(&now);
+		GetValue(TW_MILITARY_TIME, tw_military_time); 
+		if (current->tm_hour >= 12)
+		{
+			if (tw_military_time == 1)
+				sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
+			else
+				sprintf(tmp, "%d:%02d PM", current->tm_hour == 12 ? 12 : current->tm_hour - 12, current->tm_min);
 		}
-        else {
-		if (tw_military_time == 1) 
-		    sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
 		else
-		    sprintf(tmp, "%d:%02d AM", current->tm_hour == 0 ? 12 : current->tm_hour, current->tm_min);
+		{
+			if (tw_military_time == 1) 
+				sprintf(tmp, "%d:%02d", current->tm_hour, current->tm_min);
+			else
+				sprintf(tmp, "%d:%02d AM", current->tm_hour == 0 ? 12 : current->tm_hour, current->tm_min);
+		}
+		value = tmp;
+		return 0;
 	}
-        value = tmp;
-        return 0;
-    }
-    if (varName == "tw_battery")
-    {
-        char tmp[16];
+	else if (varName == "tw_battery")
+	{
+		char tmp[16];
 		static char charging = ' ';
 		static int lastVal = -1;
 		static time_t nextSecCheck = 0;
@@ -989,8 +994,8 @@
 				fgets(cap_s, 4, cap);
 				fclose(cap);
 				lastVal = atoi(cap_s);
-				if (lastVal > 100)  lastVal = 101;
-				if (lastVal < 0)    lastVal = 0;
+				if (lastVal > 100)	lastVal = 101;
+				if (lastVal < 0)	lastVal = 0;
 			}
 #ifdef TW_CUSTOM_BATTERY_PATH
 			string status_file = EXPAND(TW_CUSTOM_BATTERY_PATH);
@@ -1011,13 +1016,14 @@
 		}
 
 		sprintf(tmp, "%i%%%c", lastVal, charging);
-        value = tmp;
-        return 0;
-    }
-    return -1;
+		value = tmp;
+		return 0;
+	}
+	return -1;
 }
 
-void DataManager::Output_Version(void) {
+void DataManager::Output_Version(void)
+{
 	string Path;
 	char version[255];
 
@@ -1131,89 +1137,89 @@
 	return GetValueRef("tw_settings_path");
 }
 
-extern "C" int DataManager_ResetDefaults()
+extern "C" int DataManager_ResetDefaults(void)
 {
-    return DataManager::ResetDefaults();
+	return DataManager::ResetDefaults();
 }
 
-extern "C" void DataManager_LoadDefaults()
+extern "C" void DataManager_LoadDefaults(void)
 {
-    return DataManager::SetDefaultValues();
+	return DataManager::SetDefaultValues();
 }
 
 extern "C" int DataManager_LoadValues(const char* filename)
 {
-    return DataManager::LoadValues(filename);
+	return DataManager::LoadValues(filename);
 }
 
-extern "C" int DataManager_Flush()
+extern "C" int DataManager_Flush(void)
 {
-    return DataManager::Flush();
+	return DataManager::Flush();
 }
 
 extern "C" int DataManager_GetValue(const char* varName, char* value)
 {
-    int ret;
-    string str;
+	int ret;
+	string str;
 
-    ret = DataManager::GetValue(varName, str);
-    if (ret == 0)
-        strcpy(value, str.c_str());
-    return ret;
+	ret = DataManager::GetValue(varName, str);
+	if (ret == 0)
+		strcpy(value, str.c_str());
+	return ret;
 }
 
 extern "C" const char* DataManager_GetStrValue(const char* varName)
 {
-    string& str = DataManager::GetValueRef(varName);
-    return str.c_str();
+	string& str = DataManager::GetValueRef(varName);
+	return str.c_str();
 }
 
 extern "C" const char* DataManager_GetCurrentStoragePath(void)
 {
-    string& str = DataManager::CGetCurrentStoragePath();
-    return str.c_str();
+	string& str = DataManager::CGetCurrentStoragePath();
+	return str.c_str();
 }
 
 extern "C" const char* DataManager_GetSettingsStoragePath(void)
 {
-    string& str = DataManager::CGetSettingsStoragePath();
-    return str.c_str();
+	string& str = DataManager::CGetSettingsStoragePath();
+	return str.c_str();
 }
 
 extern "C" int DataManager_GetIntValue(const char* varName)
 {
-    return DataManager::GetIntValue(varName);
+	return DataManager::GetIntValue(varName);
 }
 
 extern "C" int DataManager_SetStrValue(const char* varName, char* value)
 {
-    return DataManager::SetValue(varName, value, 0);
+	return DataManager::SetValue(varName, value, 0);
 }
 
 extern "C" int DataManager_SetIntValue(const char* varName, int value)
 {
-    return DataManager::SetValue(varName, value, 0);
+	return DataManager::SetValue(varName, value, 0);
 }
 
 extern "C" int DataManager_SetFloatValue(const char* varName, float value)
 {
-    return DataManager::SetValue(varName, value, 0);
+	return DataManager::SetValue(varName, value, 0);
 }
 
 extern "C" int DataManager_ToggleIntValue(const char* varName)
 {
-    if (DataManager::GetIntValue(varName))
-        return DataManager::SetValue(varName, 0);
-    else
-        return DataManager::SetValue(varName, 1);
+	if (DataManager::GetIntValue(varName))
+		return DataManager::SetValue(varName, 0);
+	else
+		return DataManager::SetValue(varName, 1);
 }
 
-extern "C" void DataManager_DumpValues()
+extern "C" void DataManager_DumpValues(void)
 {
-    return DataManager::DumpValues();
+	return DataManager::DumpValues();
 }
 
-extern "C" void DataManager_ReadSettingsFile()
+extern "C" void DataManager_ReadSettingsFile(void)
 {
-    return DataManager::ReadSettingsFile();
+	return DataManager::ReadSettingsFile();
 }
diff --git a/data.h b/data.h
index 3137f8f..f9639c6 100644
--- a/data.h
+++ b/data.h
@@ -17,13 +17,13 @@
 #ifndef _DATA_HEADER
 #define _DATA_HEADER
 
-int DataManager_ResetDefaults();
-void DataManager_LoadDefaults();
+int DataManager_ResetDefaults(void);
+void DataManager_LoadDefaults(void);
 int DataManager_LoadValues(const char* filename);
-int DataManager_Flush();
+int DataManager_Flush(void);
 const char* DataManager_GetStrValue(const char* varName);
-const char* DataManager_GetCurrentStoragePath();
-const char* DataManager_GetSettingsStoragePath();
+const char* DataManager_GetCurrentStoragePath(void);
+const char* DataManager_GetSettingsStoragePath(void);
 int DataManager_GetIntValue(const char* varName);
 
 int DataManager_SetStrValue(const char* varName, char* value);
@@ -32,8 +32,8 @@
 
 int DataManager_ToggleIntValue(const char* varName);
 
-void DataManager_DumpValues();
-void DataManager_ReadSettingsFile();
+void DataManager_DumpValues(void);
+void DataManager_ReadSettingsFile(void);
 
 #endif  // _DATA_HEADER
 
diff --git a/data.hpp b/data.hpp
index ff50373..ef201d7 100644
--- a/data.hpp
+++ b/data.hpp
@@ -5,7 +5,7 @@
  * you may not use this file except in compliance with the License.
  * You may obtain a copy of the License at
  *
- *      http://www.apache.org/licenses/LICENSE-2.0
+ *    http://www.apache.org/licenses/LICENSE-2.0
  *
  * Unless required by applicable law or agreed to in writing, software
  * distributed under the License is distributed on an "AS IS" BASIS,
@@ -26,32 +26,32 @@
 class DataManager
 {
 public:
-    static int ResetDefaults();
-    static int LoadValues(const string filename);
-    static int Flush();
+	static int ResetDefaults();
+	static int LoadValues(const string filename);
+	static int Flush();
 
-    // Core get routines
-    static int GetValue(const string varName, string& value);
-    static int GetValue(const string varName, int& value);
+	// Core get routines
+	static int GetValue(const string varName, string& value);
+	static int GetValue(const string varName, int& value);
 	static int GetValue(const string varName, float& value);
-    static unsigned long long GetValue(const string varName, unsigned long long& value);
+	static unsigned long long GetValue(const string varName, unsigned long long& value);
 
-    // This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str
-    static string& GetValueRef(const string varName);
+	// This is a dangerous function. It will create the value if it doesn't exist so it has a valid c_str
+	static string& GetValueRef(const string varName);
 
-    // Helper functions
-    static string GetStrValue(const string varName);
-    static int GetIntValue(const string varName);
+	// Helper functions
+	static string GetStrValue(const string varName);
+	static int GetIntValue(const string varName);
 
-    // Core set routines
-    static int SetValue(const string varName, string value, int persist = 0);
-    static int SetValue(const string varName, int value, int persist = 0);
-    static int SetValue(const string varName, float value, int persist = 0);
-    static int SetValue(const string varName, unsigned long long value, int persist = 0);
+	// Core set routines
+	static int SetValue(const string varName, string value, int persist = 0);
+	static int SetValue(const string varName, int value, int persist = 0);
+	static int SetValue(const string varName, float value, int persist = 0);
+	static int SetValue(const string varName, unsigned long long value, int persist = 0);
 	static int SetProgress(float Fraction);
 	static int ShowProgress(float Portion, float Seconds);
 
-    static void DumpValues();
+	static void DumpValues();
 	static void update_tz_environment_variables();
 	static void SetBackupFolder();
 	static void SetDefaultValues();
@@ -64,20 +64,20 @@
 	static string& CGetSettingsStoragePath();
 
 protected:
-    typedef pair<string, int> TStrIntPair;
-    typedef pair<string, unsigned long long> TStrULLPair;
-    typedef pair<string, TStrIntPair> TNameValuePair;
-    static map<string, TStrIntPair> mValues;
-    static map<string, TStrULLPair> mULLValues;
-    static string mBackingFile;
-    static int mInitialized;
+	typedef pair<string, int> TStrIntPair;
+	typedef pair<string, unsigned long long> TStrULLPair;
+	typedef pair<string, TStrIntPair> TNameValuePair;
+	static map<string, TStrIntPair> mValues;
+	static map<string, TStrULLPair> mULLValues;
+	static string mBackingFile;
+	static int mInitialized;
 
-    static map<string, string> mConstValues;
+	static map<string, string> mConstValues;
 
 protected:
-    static int SaveValues();
+	static int SaveValues();
 
-    static int GetMagicValue(string varName, string& value);
+	static int GetMagicValue(string varName, string& value);
 
 private:
 	static void sanitize_device_id(char* device_id);
diff --git a/gui/action.cpp b/gui/action.cpp
index 3e1f793..ee33731 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -64,72 +64,72 @@
 void curtainClose(void);
 
 GUIAction::GUIAction(xml_node<>* node)
-    : Conditional(node)
+	: Conditional(node)
 {
-    xml_node<>* child;
-    xml_node<>* actions;
-    xml_attribute<>* attr;
+	xml_node<>* child;
+	xml_node<>* actions;
+	xml_attribute<>* attr;
 
-    mKey = 0;
+	mKey = 0;
 
-    if (!node)  return;
+	if (!node)  return;
 
-    // First, get the action
-    actions = node->first_node("actions");
-    if (actions)    child = actions->first_node("action");
-    else            child = node->first_node("action");
+	// First, get the action
+	actions = node->first_node("actions");
+	if (actions)	child = actions->first_node("action");
+	else			child = node->first_node("action");
 
-    if (!child) return;
+	if (!child) return;
 
-    while (child)
-    {
-        Action action;
+	while (child)
+	{
+		Action action;
 
-        attr = child->first_attribute("function");
-        if (!attr)  return;
-    
-        action.mFunction = attr->value();
-        action.mArg = child->value();
-        mActions.push_back(action);
+		attr = child->first_attribute("function");
+		if (!attr)  return;
+	
+		action.mFunction = attr->value();
+		action.mArg = child->value();
+		mActions.push_back(action);
 
-        child = child->next_sibling("action");
-    }
+		child = child->next_sibling("action");
+	}
 
-    // Now, let's get either the key or region
-    child = node->first_node("touch");
-    if (child)
-    {
-        attr = child->first_attribute("key");
-        if (attr)
-        {
-            std::string key = attr->value();
-    
-            mKey = getKeyByName(key);
-        }
-        else
-        {
-            attr = child->first_attribute("x");
-            if (!attr)  return;
-            mActionX = atol(attr->value());
-            attr = child->first_attribute("y");
-            if (!attr)  return;
-            mActionY = atol(attr->value());
-            attr = child->first_attribute("w");
-            if (!attr)  return;
-            mActionW = atol(attr->value());
-            attr = child->first_attribute("h");
-            if (!attr)  return;
-            mActionH = atol(attr->value());
-        }
-    }
+	// Now, let's get either the key or region
+	child = node->first_node("touch");
+	if (child)
+	{
+		attr = child->first_attribute("key");
+		if (attr)
+		{
+			std::string key = attr->value();
+	
+			mKey = getKeyByName(key);
+		}
+		else
+		{
+			attr = child->first_attribute("x");
+			if (!attr)  return;
+			mActionX = atol(attr->value());
+			attr = child->first_attribute("y");
+			if (!attr)  return;
+			mActionY = atol(attr->value());
+			attr = child->first_attribute("w");
+			if (!attr)  return;
+			mActionW = atol(attr->value());
+			attr = child->first_attribute("h");
+			if (!attr)  return;
+			mActionH = atol(attr->value());
+		}
+	}
 }
 
 int GUIAction::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    if (state == TOUCH_RELEASE)
-        doActions();
+	if (state == TOUCH_RELEASE)
+		doActions();
 
-    return 0;
+	return 0;
 }
 
 int GUIAction::NotifyKey(int key)
@@ -143,17 +143,17 @@
 
 int GUIAction::NotifyVarChange(std::string varName, std::string value)
 {
-    if (varName.empty() && !isConditionValid() && !mKey && !mActionW)
-        doActions();
+	if (varName.empty() && !isConditionValid() && !mKey && !mActionW)
+		doActions();
 
-    // This handles notifying the condition system of page start
-    if (varName.empty() && isConditionValid())
-        NotifyPageSet();
+	// This handles notifying the condition system of page start
+	if (varName.empty() && isConditionValid())
+		NotifyPageSet();
 
-    if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
-        doActions();
+	if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
+		doActions();
 
-    return 0;
+	return 0;
 }
 
 void GUIAction::simulate_progress_bar(void)
@@ -168,54 +168,54 @@
 
 int GUIAction::flash_zip(std::string filename, std::string pageName, const int simulate, int* wipe_cache)
 {
-    int ret_val = 0;
+	int ret_val = 0;
 
 	DataManager::SetValue("ui_progress", 0);
 
-    if (filename.empty())
-    {
-        LOGERR("No file specified.\n");
-        return -1;
-    }
+	if (filename.empty())
+	{
+		LOGERR("No file specified.\n");
+		return -1;
+	}
 
-    // We're going to jump to this page first, like a loading page
-    gui_changePage(pageName);
+	// We're going to jump to this page first, like a loading page
+	gui_changePage(pageName);
 
-    int fd = -1;
-    ZipArchive zip;
+	int fd = -1;
+	ZipArchive zip;
 
-    if (!PartitionManager.Mount_By_Path(filename, true))
+	if (!PartitionManager.Mount_By_Path(filename, true))
 		return -1;
 
 	if (mzOpenZipArchive(filename.c_str(), &zip))
-    {
-        LOGERR("Unable to open zip file.\n");
-        return -1;
-    }
+	{
+		LOGERR("Unable to open zip file.\n");
+		return -1;
+	}
 
-    // Check the zip to see if it has a custom installer theme
+	// Check the zip to see if it has a custom installer theme
 	const ZipEntry* twrp = mzFindZipEntry(&zip, "META-INF/teamwin/twrp.zip");
-    if (twrp != NULL)
-    {
-        unlink("/tmp/twrp.zip");
-        fd = creat("/tmp/twrp.zip", 0666);
-    }
-    if (fd >= 0 && twrp != NULL && 
-        mzExtractZipEntryToFile(&zip, twrp, fd) && 
-        !PageManager::LoadPackage("install", "/tmp/twrp.zip", "main"))
-    {
-        mzCloseZipArchive(&zip);
+	if (twrp != NULL)
+	{
+		unlink("/tmp/twrp.zip");
+		fd = creat("/tmp/twrp.zip", 0666);
+	}
+	if (fd >= 0 && twrp != NULL &&
+		mzExtractZipEntryToFile(&zip, twrp, fd) &&
+		!PageManager::LoadPackage("install", "/tmp/twrp.zip", "main"))
+	{
+		mzCloseZipArchive(&zip);
 		PageManager::SelectPackage("install");
-        gui_changePage("main");
-    }
-    else
-    {
-        // In this case, we just use the default page
-        mzCloseZipArchive(&zip);
+		gui_changePage("main");
+	}
+	else
+	{
+		// In this case, we just use the default page
+		mzCloseZipArchive(&zip);
 		gui_changePage(pageName);
-    }
-    if (fd >= 0)
-        close(fd);
+	}
+	if (fd >= 0)
+		close(fd);
 
 	if (simulate) {
 		simulate_progress_bar();
@@ -237,20 +237,20 @@
 		}
 	}
 
-    // Done
-    DataManager::SetValue("ui_progress", 100);
-    DataManager::SetValue("ui_progress", 0);
-    return ret_val;
+	// Done
+	DataManager::SetValue("ui_progress", 100);
+	DataManager::SetValue("ui_progress", 0);
+	return ret_val;
 }
 
 int GUIAction::doActions()
 {
-	if (mActions.size() < 1)    return -1;
-    if (mActions.size() == 1)
+	if (mActions.size() < 1)	return -1;
+	if (mActions.size() == 1)
 		return doAction(mActions.at(0), 0);
 
-    // For multi-action, we always use a thread
-    pthread_t t;
+	// For multi-action, we always use a thread
+	pthread_t t;
 	pthread_attr_t tattr;
 
 	if (pthread_attr_init(&tattr)) {
@@ -271,7 +271,7 @@
 	}
 	*/
 	int ret = pthread_create(&t, &tattr, thread_start, this);
-    if (ret) {
+	if (ret) {
 		LOGERR("Unable to create more threads for actions... continuing in same thread! %i\n", ret);
 		thread_start(this);
 	} else {
@@ -284,30 +284,30 @@
 		return -1;
 	}
 
-    return 0;
+	return 0;
 }
 
 void* GUIAction::thread_start(void *cookie)
 {
-    GUIAction* ourThis = (GUIAction*) cookie;
+	GUIAction* ourThis = (GUIAction*) cookie;
 
 	DataManager::SetValue(TW_ACTION_BUSY, 1);
 
-    if (ourThis->mActions.size() > 1)
-    {
-        std::vector<Action>::iterator iter;
-        for (iter = ourThis->mActions.begin(); iter != ourThis->mActions.end(); iter++)
-            ourThis->doAction(*iter, 1);
-    }
-    else
-    {
-        ourThis->doAction(ourThis->mActions.at(0), 1);
-    }
+	if (ourThis->mActions.size() > 1)
+	{
+		std::vector<Action>::iterator iter;
+		for (iter = ourThis->mActions.begin(); iter != ourThis->mActions.end(); iter++)
+			ourThis->doAction(*iter, 1);
+	}
+	else
+	{
+		ourThis->doAction(ourThis->mActions.at(0), 1);
+	}
 	int check = 0;
 	DataManager::GetValue("tw_background_thread_running", check);
 	if (check == 0)
 		DataManager::SetValue(TW_ACTION_BUSY, 0);
-    return NULL;
+	return NULL;
 }
 
 void GUIAction::operation_start(const string operation_name)
@@ -357,7 +357,7 @@
 
 	if (function == "reboot")
 	{
-	        //curtainClose(); this sometimes causes a crash
+			//curtainClose(); this sometimes causes a crash
 
 		sync();
 		DataManager::SetValue("tw_gui_done", 1);
@@ -365,25 +365,25 @@
 
 		return 0;
 	}
-    if (function == "home")
-    {
-        PageManager::SelectPackage("TWRP");
-        gui_changePage("main");
-        return 0;
-    }
-
-    if (function == "key")
-    {
-        PageManager::NotifyKey(getKeyByName(arg));
-        return 0;
-    }
-
-    if (function == "page") {
-		std::string page_name = gui_parse_text(arg);
-        return gui_changePage(page_name);
+	if (function == "home")
+	{
+		PageManager::SelectPackage("TWRP");
+		gui_changePage("main");
+		return 0;
 	}
 
-    if (function == "reload") {
+	if (function == "key")
+	{
+		PageManager::NotifyKey(getKeyByName(arg));
+		return 0;
+	}
+
+	if (function == "page") {
+		std::string page_name = gui_parse_text(arg);
+		return gui_changePage(page_name);
+	}
+
+	if (function == "reload") {
 		int check = 0, ret_val = 0;
 		std::string theme_path;
 
@@ -405,85 +405,85 @@
 				ret_val = 1;
 			}
 		}
-        operation_end(ret_val, simulate);
+		operation_end(ret_val, simulate);
 		return 0;
 	}
 
-    if (function == "readBackup")
-    {
+	if (function == "readBackup")
+	{
 		string Restore_Name;
 		DataManager::GetValue("tw_restore", Restore_Name);
 		PartitionManager.Set_Restore_Files(Restore_Name);
-        return 0;
-    }
+		return 0;
+	}
 
-    if (function == "set")
-    {
-        if (arg.find('=') != string::npos)
-        {
-            string varName = arg.substr(0, arg.find('='));
-            string value = arg.substr(arg.find('=') + 1, string::npos);
+	if (function == "set")
+	{
+		if (arg.find('=') != string::npos)
+		{
+			string varName = arg.substr(0, arg.find('='));
+			string value = arg.substr(arg.find('=') + 1, string::npos);
 
-            DataManager::GetValue(value, value);
-            DataManager::SetValue(varName, value);
-        }
-        else
-            DataManager::SetValue(arg, "1");
-        return 0;
-    }
-    if (function == "clear")
-    {
-        DataManager::SetValue(arg, "0");
-        return 0;
-    }
+			DataManager::GetValue(value, value);
+			DataManager::SetValue(varName, value);
+		}
+		else
+			DataManager::SetValue(arg, "1");
+		return 0;
+	}
+	if (function == "clear")
+	{
+		DataManager::SetValue(arg, "0");
+		return 0;
+	}
 
-    if (function == "mount")
-    {
-        if (arg == "usb")
-        {
-            DataManager::SetValue(TW_ACTION_BUSY, 1);
+	if (function == "mount")
+	{
+		if (arg == "usb")
+		{
+			DataManager::SetValue(TW_ACTION_BUSY, 1);
 			if (!simulate)
 				PartitionManager.usb_storage_enable();
 			else
 				gui_print("Simulating actions...\n");
-        }
-        else if (!simulate)
-        {
-            string cmd;
+		}
+		else if (!simulate)
+		{
+			string cmd;
 			if (arg == "EXTERNAL")
 				PartitionManager.Mount_By_Path(DataManager::GetStrValue(TW_EXTERNAL_MOUNT), true);
 			else if (arg == "INTERNAL")
 				PartitionManager.Mount_By_Path(DataManager::GetStrValue(TW_INTERNAL_MOUNT), true);
 			else
 				PartitionManager.Mount_By_Path(arg, true);
-        } else
+		} else
 			gui_print("Simulating actions...\n");
-        return 0;
-    }
+		return 0;
+	}
 
-    if (function == "umount" || function == "unmount")
-    {
-        if (arg == "usb")
-        {
-            if (!simulate)
+	if (function == "umount" || function == "unmount")
+	{
+		if (arg == "usb")
+		{
+			if (!simulate)
 				PartitionManager.usb_storage_disable();
 			else
 				gui_print("Simulating actions...\n");
 			DataManager::SetValue(TW_ACTION_BUSY, 0);
-        }
-        else if (!simulate)
-        {
-            string cmd;
+		}
+		else if (!simulate)
+		{
+			string cmd;
 			if (arg == "EXTERNAL")
 				PartitionManager.UnMount_By_Path(DataManager::GetStrValue(TW_EXTERNAL_MOUNT), true);
 			else if (arg == "INTERNAL")
 				PartitionManager.UnMount_By_Path(DataManager::GetStrValue(TW_INTERNAL_MOUNT), true);
 			else
 				PartitionManager.UnMount_By_Path(arg, true);
-        } else
+		} else
 			gui_print("Simulating actions...\n");
-        return 0;
-    }
+		return 0;
+	}
 	
 	if (function == "restoredefaultsettings")
 	{
@@ -519,20 +519,20 @@
 	if (function == "compute" || function == "addsubtract")
 	{
 		if (arg.find("+") != string::npos)
-        {
-            string varName = arg.substr(0, arg.find('+'));
-            string string_to_add = arg.substr(arg.find('+') + 1, string::npos);
+		{
+			string varName = arg.substr(0, arg.find('+'));
+			string string_to_add = arg.substr(arg.find('+') + 1, string::npos);
 			int amount_to_add = atoi(string_to_add.c_str());
 			int value;
 
 			DataManager::GetValue(varName, value);
-            DataManager::SetValue(varName, value + amount_to_add);
+			DataManager::SetValue(varName, value + amount_to_add);
 			return 0;
-        }
+		}
 		if (arg.find("-") != string::npos)
-        {
-            string varName = arg.substr(0, arg.find('-'));
-            string string_to_subtract = arg.substr(arg.find('-') + 1, string::npos);
+		{
+			string varName = arg.substr(0, arg.find('-'));
+			string string_to_subtract = arg.substr(arg.find('-') + 1, string::npos);
 			int amount_to_subtract = atoi(string_to_subtract.c_str());
 			int value;
 
@@ -540,9 +540,9 @@
 			value -= amount_to_subtract;
 			if (value <= 0)
 				value = 0;
-            DataManager::SetValue(varName, value);
+			DataManager::SetValue(varName, value);
 			return 0;
-        }
+		}
 		if (arg.find("*") != string::npos)
 		{
 			string varName = arg.substr(0, arg.find('*'));
@@ -653,11 +653,11 @@
 	}
 	
 	if (function == "overlay")
-        return gui_changeOverlay(arg);
+		return gui_changeOverlay(arg);
 
 	if (function == "queuezip")
-    {
-        if (zip_queue_index >= 10) {
+	{
+		if (zip_queue_index >= 10) {
 			gui_print("Maximum zip queue reached!\n");
 			return 0;
 		}
@@ -670,8 +670,8 @@
 	}
 
 	if (function == "cancelzip")
-    {
-        if (zip_queue_index <= 0) {
+	{
+		if (zip_queue_index <= 0) {
 			gui_print("Minimum zip queue reached!\n");
 			return 0;
 		} else {
@@ -696,9 +696,9 @@
 		return 0;
 	}
 
-    if (isThreaded)
-    {
-        if (function == "fileexists")
+	if (isThreaded)
+	{
+		if (function == "fileexists")
 		{
 			struct stat st;
 			string newpath = arg + "/.";
@@ -712,13 +712,13 @@
 		}
 
 		if (function == "flash")
-        {
+		{
 			int i, ret_val = 0, wipe_cache = 0;
 
 			for (i=0; i<zip_queue_index; i++) {
 				operation_start("Flashing");
-		        DataManager::SetValue("tw_filename", zip_queue[i]);
-		        DataManager::SetValue(TW_ZIP_INDEX, (i + 1));
+				DataManager::SetValue("tw_filename", zip_queue[i]);
+				DataManager::SetValue(TW_ZIP_INDEX, (i + 1));
 
 				ret_val = flash_zip(zip_queue[i], arg, simulate, &wipe_cache);
 				if (ret_val != 0) {
@@ -751,12 +751,12 @@
 			}
 			PartitionManager.Update_System_Details();
 			operation_end(ret_val, simulate);
-            return 0;
-        }
-        if (function == "wipe")
-        {
-            operation_start("Format");
-            DataManager::SetValue("tw_partition", arg);
+			return 0;
+		}
+		if (function == "wipe")
+		{
+			operation_start("Format");
+			DataManager::SetValue("tw_partition", arg);
 
 			int ret_val = false;
 
@@ -863,9 +863,9 @@
 				ret_val = 0; // 0 is success
 			else
 				ret_val = 1; // 1 is failure
-            operation_end(ret_val, simulate);
-            return 0;
-        }
+			operation_end(ret_val, simulate);
+			return 0;
+		}
 		if (function == "refreshsizes")
 		{
 			operation_start("Refreshing Sizes");
@@ -876,9 +876,9 @@
 			operation_end(0, simulate);
 			return 0;
 		}
-        if (function == "nandroid")
-        {
-            operation_start("Nandroid");
+		if (function == "nandroid")
+		{
+			operation_start("Nandroid");
 			int ret = 0;
 
 			if (simulate) {
@@ -910,13 +910,13 @@
 				ret = 1; // 1 for failure
 			else
 				ret = 0; // 0 for success
-            operation_end(ret, simulate);
+			operation_end(ret, simulate);
 			return 0;
-        }
+		}
 		if (function == "fixpermissions")
 		{
 			operation_start("Fix Permissions");
-            LOGINFO("fix permissions started!\n");
+			LOGINFO("fix permissions started!\n");
 			if (simulate) {
 				simulate_progress_bar();
 			} else {
@@ -927,9 +927,9 @@
 			}
 			return 0;
 		}
-        if (function == "dd")
-        {
-            operation_start("imaging");
+		if (function == "dd")
+		{
+			operation_start("imaging");
 
 			if (simulate) {
 				simulate_progress_bar();
@@ -938,9 +938,9 @@
 				string cmd = "dd " + arg;
 				TWFunc::Exec_Cmd(cmd, result);
 			}
-            operation_end(0, simulate);
-            return 0;
-        }
+			operation_end(0, simulate);
+			return 0;
+		}
 		if (function == "partitionsd")
 		{
 			operation_start("Partition SD Card");
@@ -1292,26 +1292,26 @@
 			operation_end(op_status, simulate);
 			return 0;
 		}
-    }
-    else
-    {
+	}
+	else
+	{
 		pthread_t t;
 		pthread_create(&t, NULL, thread_start, this);
-        return 0;
-    }
+		return 0;
+	}
 	LOGERR("Unknown action '%s'\n", function.c_str());
-    return -1;
+	return -1;
 }
 
 int GUIAction::getKeyByName(std::string key)
 {
-    if (key == "home")          return KEY_HOME;
-    else if (key == "menu")     return KEY_MENU;
-    else if (key == "back")     return KEY_BACK;
-    else if (key == "search")   return KEY_SEARCH;
-    else if (key == "voldown")  return KEY_VOLUMEDOWN;
-    else if (key == "volup")    return KEY_VOLUMEUP;
-    else if (key == "power") {
+	if (key == "home")			return KEY_HOME;
+	else if (key == "menu")		return KEY_MENU;
+	else if (key == "back")	 	return KEY_BACK;
+	else if (key == "search")	return KEY_SEARCH;
+	else if (key == "voldown")	return KEY_VOLUMEDOWN;
+	else if (key == "volup")	return KEY_VOLUMEUP;
+	else if (key == "power") {
 		int ret_val;
 		DataManager::GetValue(TW_POWER_BUTTON, ret_val);
 		if (!ret_val)
@@ -1320,7 +1320,7 @@
 			return ret_val;
 	}
 
-    return atol(key.c_str());
+	return atol(key.c_str());
 }
 
 void* GUIAction::command_thread(void *cookie)
diff --git a/gui/animation.cpp b/gui/animation.cpp
index 77d7b54..8c92278 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -28,109 +28,109 @@
 
 GUIAnimation::GUIAnimation(xml_node<>* node)
 {
-    xml_node<>* child;
-    xml_attribute<>* attr;
+	xml_node<>* child;
+	xml_attribute<>* attr;
 
-    mAnimation = NULL;
-    mFrame = 1;
-    mFPS = 1;
-    mLoop = -1;
-    mRender = 1;
-    mUpdateCount = 0;
+	mAnimation = NULL;
+	mFrame = 1;
+	mFPS = 1;
+	mLoop = -1;
+	mRender = 1;
+	mUpdateCount = 0;
 
-    if (!node)  return;
+	if (!node)  return;
 
-    child = node->first_node("resource");
-    if (child)
-    {
-        attr = child->first_attribute("name");
-        if (attr)
-            mAnimation = (AnimationResource*) PageManager::FindResource(attr->value());
-    }
+	child = node->first_node("resource");
+	if (child)
+	{
+		attr = child->first_attribute("name");
+		if (attr)
+			mAnimation = (AnimationResource*) PageManager::FindResource(attr->value());
+	}
 
-    // Load the placement
-    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement);
+	// Load the placement
+	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement);
 
-    child = node->first_node("speed");
-    if (child)
-    {
-        attr = child->first_attribute("fps");
-        if (attr)
-            mFPS = atoi(attr->value());
-        attr = child->first_attribute("render");
-        if (attr)
-            mRender = atoi(attr->value());
-    }
-    if (mFPS > 30)  mFPS = 30;
+	child = node->first_node("speed");
+	if (child)
+	{
+		attr = child->first_attribute("fps");
+		if (attr)
+			mFPS = atoi(attr->value());
+		attr = child->first_attribute("render");
+		if (attr)
+			mRender = atoi(attr->value());
+	}
+	if (mFPS > 30)  mFPS = 30;
 
-    child = node->first_node("loop");
-    if (child)
-    {
-        attr = child->first_attribute("frame");
-        if (attr)
-            mLoop = atoi(attr->value()) - 1;
-        attr = child->first_attribute("start");
-        if (attr)
-            mFrame = atoi(attr->value());
-    }
+	child = node->first_node("loop");
+	if (child)
+	{
+		attr = child->first_attribute("frame");
+		if (attr)
+			mLoop = atoi(attr->value()) - 1;
+		attr = child->first_attribute("start");
+		if (attr)
+			mFrame = atoi(attr->value());
+	}
 
-    // Fetch the render sizes
-    if (mAnimation && mAnimation->GetResource())
-    {
-        mRenderW = gr_get_width(mAnimation->GetResource());
-        mRenderH = gr_get_height(mAnimation->GetResource());
+	// Fetch the render sizes
+	if (mAnimation && mAnimation->GetResource())
+	{
+		mRenderW = gr_get_width(mAnimation->GetResource());
+		mRenderH = gr_get_height(mAnimation->GetResource());
 
-        // Adjust for placement
-        if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
-        {
-            if (mPlacement == CENTER)
-                mRenderX -= (mRenderW / 2);
-            else
-                mRenderX -= mRenderW;
-        }
-        if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
-        {
-            if (mPlacement == CENTER)
-                mRenderY -= (mRenderH / 2);
-            else
-                mRenderY -= mRenderH;
-        }
-        SetPlacement(TOP_LEFT);
-    }
+		// Adjust for placement
+		if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
+		{
+			if (mPlacement == CENTER)
+				mRenderX -= (mRenderW / 2);
+			else
+				mRenderX -= mRenderW;
+		}
+		if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
+		{
+			if (mPlacement == CENTER)
+				mRenderY -= (mRenderH / 2);
+			else
+				mRenderY -= mRenderH;
+		}
+		SetPlacement(TOP_LEFT);
+	}
 }
 
 int GUIAnimation::Render(void)
 {
-    if (!mAnimation || !mAnimation->GetResource(mFrame))      return -1;
+	if (!mAnimation || !mAnimation->GetResource(mFrame))	return -1;
 
-    gr_blit(mAnimation->GetResource(mFrame), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
-    return 0;
+	gr_blit(mAnimation->GetResource(mFrame), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
+	return 0;
 }
 
 int GUIAnimation::Update(void)
 {
-    if (!mAnimation)        return -1;
+	if (!mAnimation)		return -1;
 
-    // Handle the "end-of-animation" state
-    if (mLoop == -2)        return 0;
+	// Handle the "end-of-animation" state
+	if (mLoop == -2)		return 0;
 
-    // Determine if we need the next frame yet...
-    if (++mUpdateCount > 30 / mFPS)
-    {
-        mUpdateCount = 0;
-        if (++mFrame >= mAnimation->GetResourceCount())
-        {
-            if (mLoop < 0)
-            {
-                mFrame = mAnimation->GetResourceCount() - 1;
-                mLoop = -2;
-            }
-            else
-                mFrame = mLoop;
-        }
-        if (mRender == 2)   return 2;
-        return (Render() == 0 ? 1 : -1);
-    }
-    return 0;
+	// Determine if we need the next frame yet...
+	if (++mUpdateCount > 30 / mFPS)
+	{
+		mUpdateCount = 0;
+		if (++mFrame >= mAnimation->GetResourceCount())
+		{
+			if (mLoop < 0)
+			{
+				mFrame = mAnimation->GetResourceCount() - 1;
+				mLoop = -2;
+			}
+			else
+				mFrame = mLoop;
+		}
+		if (mRender == 2)	return 2;
+		return (Render() == 0 ? 1 : -1);
+	}
+	return 0;
 }
 
diff --git a/gui/blanktimer.hpp b/gui/blanktimer.hpp
index 60d5b1b..01c1dfb 100644
--- a/gui/blanktimer.hpp
+++ b/gui/blanktimer.hpp
@@ -24,31 +24,35 @@
 
 using namespace std;
 
-class blanktimer {
-	public:
-		blanktimer(void);
-		int setTimerThread(void);
-		void resetTimerAndUnblank(void);
-		void setTime(int newtime);
-		bool IsScreenOff();
+class blanktimer
+{
+public:
+	blanktimer(void);
 
-	private:
-		void setConBlank(int blank);
-		void setTimer(void);
-		timespec getTimer(void);
-		int getBrightness(void);
-		int setBrightness(int brightness);
-		int setBlankTimer(void);
-		int setClockTimer(void);
-		typedef int (blanktimer::*ThreadPtr)(void);
-		typedef void* (*PThreadPtr)(void*);
-		pthread_mutex_t conblankmutex;
-		pthread_mutex_t timermutex;
-		int conblank;
-		timespec btimer;
-		unsigned long long sleepTimer;
-		int orig_brightness;
-		bool screenoff;
+	int setTimerThread(void);
+	void resetTimerAndUnblank(void);
+	void setTime(int newtime);
+	bool IsScreenOff();
+
+private:
+	typedef int (blanktimer::*ThreadPtr)(void);
+	typedef void* (*PThreadPtr)(void*);
+
+	void setConBlank(int blank);
+	void setTimer(void);
+	timespec getTimer(void);
+	int getBrightness(void);
+	int setBrightness(int brightness);
+	int setBlankTimer(void);
+	int setClockTimer(void);
+
+	pthread_mutex_t conblankmutex;
+	pthread_mutex_t timermutex;
+	int conblank;
+	timespec btimer;
+	unsigned long long sleepTimer;
+	int orig_brightness;
+	bool screenoff;
 };
 
 extern blanktimer blankTimer;
diff --git a/gui/button.cpp b/gui/button.cpp
index af7d07b..9fc85a0 100644
--- a/gui/button.cpp
+++ b/gui/button.cpp
@@ -42,42 +42,42 @@
 #include "objects.hpp"
 
 GUIButton::GUIButton(xml_node<>* node)
-    : Conditional(node)
+	: Conditional(node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mButtonImg = NULL;
-    mButtonIcon = NULL;
-    mButtonLabel = NULL;
-    mAction = NULL;
-    mRendered = false;
+	mButtonImg = NULL;
+	mButtonIcon = NULL;
+	mButtonLabel = NULL;
+	mAction = NULL;
+	mRendered = false;
 	hasHighlightColor = false;
 	renderHighlight = false;
 	hasFill = false;
 
-    if (!node)  return;
+	if (!node)  return;
 
-    // Three of the four can be loaded directly from the node
-    mButtonImg = new GUIImage(node);
-    mButtonLabel = new GUIText(node);
-    mAction = new GUIAction(node);
+	// Three of the four can be loaded directly from the node
+	mButtonImg = new GUIImage(node);
+	mButtonLabel = new GUIText(node);
+	mAction = new GUIAction(node);
 
-    if (mButtonImg->Render() < 0)
-    {
-        delete mButtonImg;
-        mButtonImg = NULL;
-    }
-    if (mButtonLabel->Render() < 0)
-    {
-        delete mButtonLabel;
-        mButtonLabel = NULL;
-    }
+	if (mButtonImg->Render() < 0)
+	{
+		delete mButtonImg;
+		mButtonImg = NULL;
+	}
+	if (mButtonLabel->Render() < 0)
+	{
+		delete mButtonLabel;
+		mButtonLabel = NULL;
+	}
 	// Load fill if it exists
 	memset(&mFillColor, 0, sizeof(COLOR));
 	child = node->first_node("fill");
-    if (child)
-    {
+	if (child)
+	{
 		attr = child->first_attribute("color");
 		if (attr) {
 			hasFill = true;
@@ -89,14 +89,14 @@
 		LOGERR("No image resource or fill specified for button.\n");
 	}
 
-    // The icon is a special case
-    child = node->first_node("icon");
-    if (child)
-    {
-        attr = child->first_attribute("resource");
-        if (attr)
-            mButtonIcon = PageManager::FindResource(attr->value());
-    }
+	// The icon is a special case
+	child = node->first_node("icon");
+	if (child)
+	{
+		attr = child->first_attribute("resource");
+		if (attr)
+			mButtonIcon = PageManager::FindResource(attr->value());
+	}
 
 	memset(&mHighlightColor, 0, sizeof(COLOR));
 	child = node->first_node("highlight");
@@ -109,43 +109,43 @@
 		}
 	}
 
-    int x, y, w, h;
-    if (mButtonImg) {
+	int x, y, w, h;
+	if (mButtonImg) {
 		mButtonImg->GetRenderPos(x, y, w, h);
 	} else if (hasFill) {
 		LoadPlacement(node->first_node("placement"), &x, &y, &w, &h);
 	}
 	SetRenderPos(x, y, w, h);
-    return;
+	return;
 }
 
 GUIButton::~GUIButton()
 {
-    if (mButtonImg)     delete mButtonImg;
-    if (mButtonLabel)   delete mButtonLabel;
-    if (mAction)        delete mAction;
-	if (mButtonIcon)    delete mButtonIcon;
+	if (mButtonImg)	 	delete mButtonImg;
+	if (mButtonLabel)   delete mButtonLabel;
+	if (mAction)		delete mAction;
+	if (mButtonIcon)	delete mButtonIcon;
 }
 
 int GUIButton::Render(void)
 {
-    if (!isConditionTrue())
-    {
-        mRendered = false;
-        return 0;
-    }
+	if (!isConditionTrue())
+	{
+		mRendered = false;
+		return 0;
+	}
 
-    int ret = 0;
+	int ret = 0;
 
-    if (mButtonImg)     ret = mButtonImg->Render();
-    if (ret < 0)        return ret;
+	if (mButtonImg)	 ret = mButtonImg->Render();
+	if (ret < 0)		return ret;
 	if (hasFill) {
 		gr_color(mFillColor.red, mFillColor.green, mFillColor.blue, mFillColor.alpha);
 		gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
 	}
-    if (mButtonIcon && mButtonIcon->GetResource())
-        gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY);
-    if (mButtonLabel) {
+	if (mButtonIcon && mButtonIcon->GetResource())
+		gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY);
+	if (mButtonLabel) {
 		int w, h;
 		mButtonLabel->GetCurrentBounds(w, h);
 		if (w != mTextW) {
@@ -163,109 +163,109 @@
 			mButtonLabel->SetRenderPos(mTextX, mTextY);
 		}
 		ret = mButtonLabel->Render();
-		if (ret < 0)        return ret;
+		if (ret < 0)		return ret;
 	}
 	if (renderHighlight && hasHighlightColor) {
 		gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
 		gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
 	}
-    mRendered = true;
-    return ret;
+	mRendered = true;
+	return ret;
 }
 
 int GUIButton::Update(void)
 {
-    if (!isConditionTrue())     return (mRendered ? 2 : 0);
-    if (!mRendered)             return 2;
+	if (!isConditionTrue())	return (mRendered ? 2 : 0);
+	if (!mRendered)			return 2;
 
-    int ret = 0, ret2 = 0;
+	int ret = 0, ret2 = 0;
 
-    if (mButtonImg)             ret = mButtonImg->Update();
-    if (ret < 0)            return ret;
+	if (mButtonImg)			ret = mButtonImg->Update();
+	if (ret < 0)			return ret;
 
-    if (ret == 0)
-    {
-        if (mButtonLabel) {
+	if (ret == 0)
+	{
+		if (mButtonLabel) {
 			ret2 = mButtonLabel->Update();
-			if (ret2 < 0)       return ret2;
-			if (ret2 > ret)     ret = ret2;
+			if (ret2 < 0)	return ret2;
+			if (ret2 > ret)	ret = ret2;
 		}
-    }
-    else if (ret == 1)
-    {
-        // The button re-rendered, so everyone else is a render
-        if (mButtonIcon && mButtonIcon->GetResource())
-            gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY);
-        if (mButtonLabel)   ret = mButtonLabel->Render();
-        if (ret < 0)        return ret;
-        ret = 1;
-    }
-    else
-    {
-        // Aparently, the button needs a background update
-        ret = 2;
-    }
-    return ret;
+	}
+	else if (ret == 1)
+	{
+		// The button re-rendered, so everyone else is a render
+		if (mButtonIcon && mButtonIcon->GetResource())
+			gr_blit(mButtonIcon->GetResource(), 0, 0, mIconW, mIconH, mIconX, mIconY);
+		if (mButtonLabel)   ret = mButtonLabel->Render();
+		if (ret < 0)		return ret;
+		ret = 1;
+	}
+	else
+	{
+		// Aparently, the button needs a background update
+		ret = 2;
+	}
+	return ret;
 }
 
 int GUIButton::SetRenderPos(int x, int y, int w, int h)
 {
-    mRenderX = x;
-    mRenderY = y;
-    if (w || h)
-    {
-        mRenderW = w;
-        mRenderH = h;
-    }
+	mRenderX = x;
+	mRenderY = y;
+	if (w || h)
+	{
+		mRenderW = w;
+		mRenderH = h;
+	}
 
-    mIconW = 0;     mIconH = 0;
-    if (mButtonIcon && mButtonIcon->GetResource())
-    {
-        mIconW = gr_get_width(mButtonIcon->GetResource());
-        mIconH = gr_get_height(mButtonIcon->GetResource());
-    }
+	mIconW = 0;	 mIconH = 0;
+	if (mButtonIcon && mButtonIcon->GetResource())
+	{
+		mIconW = gr_get_width(mButtonIcon->GetResource());
+		mIconH = gr_get_height(mButtonIcon->GetResource());
+	}
 
-    mTextH = 0;
-    mTextW = 0;
-    mIconX = mRenderX + ((mRenderW - mIconW) / 2);
-    if (mButtonLabel)   mButtonLabel->GetCurrentBounds(mTextW, mTextH);
-    if (mTextW)
-    {
-        // As a special case, we'll allow large text which automatically moves it to the right.
-        if (mTextW > mRenderW)
-        {
-            mTextX = mRenderW + mRenderX + 5;
-            mRenderW += mTextW + 5;
-        }
-        else
-        {
-            mTextX = mRenderX + ((mRenderW - mTextW) / 2);
-        }
-    }
+	mTextH = 0;
+	mTextW = 0;
+	mIconX = mRenderX + ((mRenderW - mIconW) / 2);
+	if (mButtonLabel)   mButtonLabel->GetCurrentBounds(mTextW, mTextH);
+	if (mTextW)
+	{
+		// As a special case, we'll allow large text which automatically moves it to the right.
+		if (mTextW > mRenderW)
+		{
+			mTextX = mRenderW + mRenderX + 5;
+			mRenderW += mTextW + 5;
+		}
+		else
+		{
+			mTextX = mRenderX + ((mRenderW - mTextW) / 2);
+		}
+	}
 
-    if (mIconH == 0 || mTextH == 0 || mIconH + mTextH > mRenderH)
-    {
-        mIconY = mRenderY + (mRenderH / 2) - (mIconH / 2);
-        mTextY = mRenderY + (mRenderH / 2) - (mTextH / 2);
-    }
-    else
-    {
-        int divisor = mRenderH - (mIconH + mTextH);
-        mIconY = mRenderY + (divisor / 3);
-        mTextY = mRenderY + (divisor * 2 / 3) + mIconH;
-    }
+	if (mIconH == 0 || mTextH == 0 || mIconH + mTextH > mRenderH)
+	{
+		mIconY = mRenderY + (mRenderH / 2) - (mIconH / 2);
+		mTextY = mRenderY + (mRenderH / 2) - (mTextH / 2);
+	}
+	else
+	{
+		int divisor = mRenderH - (mIconH + mTextH);
+		mIconY = mRenderY + (divisor / 3);
+		mTextY = mRenderY + (divisor * 2 / 3) + mIconH;
+	}
 
-    if (mButtonLabel)   mButtonLabel->SetRenderPos(mTextX, mTextY);
-    if (mAction)        mAction->SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
-    SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
-    return 0;
+	if (mButtonLabel)   mButtonLabel->SetRenderPos(mTextX, mTextY);
+	if (mAction)		mAction->SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
+	SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
+	return 0;
 }
 
 int GUIButton::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
 	static int last_state = 0;
 
-	if (!isConditionTrue())     return -1;
+	if (!isConditionTrue())	 return -1;
 	if (x < mRenderX || x - mRenderX > mRenderW || y < mRenderY || y - mRenderY > mRenderH || state == TOUCH_RELEASE) {
 		if (last_state == 1) {
 			last_state = 0;
@@ -289,6 +289,5 @@
 	}
 	if (x < mRenderX || x - mRenderX > mRenderW || y < mRenderY || y - mRenderY > mRenderH)
 		return 0;
-    return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
+	return (mAction ? mAction->NotifyTouch(state, x, y) : 1);
 }
-
diff --git a/gui/checkbox.cpp b/gui/checkbox.cpp
index 077d5e2..b6d5e63 100644
--- a/gui/checkbox.cpp
+++ b/gui/checkbox.cpp
@@ -26,63 +26,64 @@
 #include "objects.hpp"
 
 GUICheckbox::GUICheckbox(xml_node<>* node)
-    : Conditional(node)
+	: Conditional(node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mChecked = NULL;
-    mUnchecked = NULL;
-    mLabel = NULL;
-    mRendered = false;
+	mChecked = NULL;
+	mUnchecked = NULL;
+	mLabel = NULL;
+	mRendered = false;
 
-    mLastState = 0;
+	mLastState = 0;
 
-    if (!node)  return;
+	if (!node)
+		return;
 
-    // The label can be loaded directly
-    mLabel = new GUIText(node);
+	// The label can be loaded directly
+	mLabel = new GUIText(node);
 
-    // Read the check states
-    child = node->first_node("image");
-    if (child)
-    {
-        attr = child->first_attribute("checked");
-        if (attr)
-            mChecked = PageManager::FindResource(attr->value());
-        attr = child->first_attribute("unchecked");
-        if (attr)
-            mUnchecked = PageManager::FindResource(attr->value());
-    }
+	// Read the check states
+	child = node->first_node("image");
+	if (child)
+	{
+		attr = child->first_attribute("checked");
+		if (attr)
+			mChecked = PageManager::FindResource(attr->value());
+		attr = child->first_attribute("unchecked");
+		if (attr)
+			mUnchecked = PageManager::FindResource(attr->value());
+	}
 
-    // Get the variable data
-    child = node->first_node("data");
-    if (child)
-    {
-        attr = child->first_attribute("variable");
-        if (attr)
-            mVarName = attr->value();
-        attr = child->first_attribute("default");
-        if (attr)
-            DataManager::SetValue(mVarName, attr->value());
-    }
+	// Get the variable data
+	child = node->first_node("data");
+	if (child)
+	{
+		attr = child->first_attribute("variable");
+		if (attr)
+			mVarName = attr->value();
+		attr = child->first_attribute("default");
+		if (attr)
+			DataManager::SetValue(mVarName, attr->value());
+	}
 
-    mCheckW = 0;    mCheckH = 0;
-    if (mChecked && mChecked->GetResource())
-    {
-        mCheckW = gr_get_width(mChecked->GetResource());
-        mCheckH = gr_get_height(mChecked->GetResource());
-    }
-    else if (mUnchecked && mUnchecked->GetResource())
-    {
-        mCheckW = gr_get_width(mUnchecked->GetResource());
-        mCheckH = gr_get_height(mUnchecked->GetResource());
-    }
+	mCheckW = 0;	mCheckH = 0;
+	if (mChecked && mChecked->GetResource())
+	{
+		mCheckW = gr_get_width(mChecked->GetResource());
+		mCheckH = gr_get_height(mChecked->GetResource());
+	}
+	else if (mUnchecked && mUnchecked->GetResource())
+	{
+		mCheckW = gr_get_width(mUnchecked->GetResource());
+		mCheckH = gr_get_height(mUnchecked->GetResource());
+	}
 
-    int x, y, w, h;
-    mLabel->GetRenderPos(x, y, w, h);
-    SetRenderPos(x, y, 0, 0);
-    return;
+	int x, y, w, h;
+	mLabel->GetRenderPos(x, y, w, h);
+	SetRenderPos(x, y, 0, 0);
+	return;
 }
 
 GUICheckbox::~GUICheckbox()
@@ -91,78 +92,81 @@
 
 int GUICheckbox::Render(void)
 {
-    if (!isConditionTrue())
-    {
-        mRendered = false;
-        return 0;
-    }
+	if (!isConditionTrue())
+	{
+		mRendered = false;
+		return 0;
+	}
 
-    int ret = 0;
-    int lastState = 0;
-    DataManager::GetValue(mVarName, lastState);
+	int ret = 0;
+	int lastState = 0;
+	DataManager::GetValue(mVarName, lastState);
 
-    if (lastState)
-    {
-        if (mChecked && mChecked->GetResource())
-            gr_blit(mChecked->GetResource(), 0, 0, mCheckW, mCheckH, mRenderX, mRenderY);
-    }
-    else
-    {
-        if (mUnchecked && mUnchecked->GetResource())
-            gr_blit(mUnchecked->GetResource(), 0, 0, mCheckW, mCheckH, mRenderX, mRenderY);
-    }
-    if (mLabel)     ret = mLabel->Render();
-    mLastState = lastState;
-    mRendered = true;
-    return ret;
+	if (lastState)
+	{
+		if (mChecked && mChecked->GetResource())
+			gr_blit(mChecked->GetResource(), 0, 0, mCheckW, mCheckH, mRenderX, mRenderY);
+	}
+	else
+	{
+		if (mUnchecked && mUnchecked->GetResource())
+			gr_blit(mUnchecked->GetResource(), 0, 0, mCheckW, mCheckH, mRenderX, mRenderY);
+	}
+	if (mLabel)
+		ret = mLabel->Render();
+	mLastState = lastState;
+	mRendered = true;
+	return ret;
 }
 
 int GUICheckbox::Update(void)
 {
-    if (!isConditionTrue())     return (mRendered ? 2 : 0);
-    if (!mRendered)             return 2;
+	if (!isConditionTrue())	return (mRendered ? 2 : 0);
+	if (!mRendered)			return 2;
 
-    int lastState = 0;
-    DataManager::GetValue(mVarName, lastState);
+	int lastState = 0;
+	DataManager::GetValue(mVarName, lastState);
 
-    if (lastState != mLastState)
-        return 2;
-    return 0;
+	if (lastState != mLastState)
+		return 2;
+	return 0;
 }
 
 int GUICheckbox::SetRenderPos(int x, int y, int w, int h)
 {
-    mRenderX = x;
-    mRenderY = y;
+	mRenderX = x;
+	mRenderY = y;
 
-    if (w || h)     return -1;
+	if (w || h)
+		return -1;
 
-    int textW, textH;
-    mLabel->GetCurrentBounds(textW, textH);
+	int textW, textH;
+	mLabel->GetCurrentBounds(textW, textH);
 
-    w = textW + mCheckW + 5;
-    mRenderW = w;
-    mRenderH = mCheckH;
+	w = textW + mCheckW + 5;
+	mRenderW = w;
+	mRenderH = mCheckH;
 
-    mTextX = mRenderX + mCheckW + 5;
-    mTextY = mRenderY + ((mCheckH / 2) - (textH / 2));
+	mTextX = mRenderX + mCheckW + 5;
+	mTextY = mRenderY + ((mCheckH / 2) - (textH / 2));
 
-    mLabel->SetRenderPos(mTextX, mTextY, 0, 0);
-    SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
-    return 0;
+	mLabel->SetRenderPos(mTextX, mTextY, 0, 0);
+	SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
+	return 0;
 }
 
 int GUICheckbox::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    if (!isConditionTrue())     return -1;
+	if (!isConditionTrue())
+		return -1;
 
-    if (state == TOUCH_RELEASE)
-    {
-        int lastState;
-        DataManager::GetValue(mVarName, lastState);
-        lastState = (lastState == 0) ? 1 : 0;
-        DataManager::SetValue(mVarName, lastState);
-    }
-    return 0;
+	if (state == TOUCH_RELEASE)
+	{
+		int lastState;
+		DataManager::GetValue(mVarName, lastState);
+		lastState = (lastState == 0) ? 1 : 0;
+		DataManager::SetValue(mVarName, lastState);
+	}
+	return 0;
 }
 
diff --git a/gui/conditional.cpp b/gui/conditional.cpp
index b3aba2d..5ea8d17 100644
--- a/gui/conditional.cpp
+++ b/gui/conditional.cpp
@@ -29,153 +29,156 @@
 
 Conditional::Conditional(xml_node<>* node)
 {
-    // Break out early, it's too hard to check if valid every step
-    if (!node)          return;
+	// Break out early, it's too hard to check if valid every step
+	if (!node)		return;
 
-    // First, get the action
-    xml_node<>* condition = node->first_node("conditions");
-    if (condition)  condition = condition->first_node("condition");
-    else            condition = node->first_node("condition");
+	// First, get the action
+	xml_node<>* condition = node->first_node("conditions");
+	if (condition)  condition = condition->first_node("condition");
+	else			condition = node->first_node("condition");
 
-    if (!condition)     return;
+	if (!condition)	return;
 
-    while (condition)
-    {
-        Condition cond;
+	while (condition)
+	{
+		Condition cond;
 
-        cond.mCompareOp = "=";
+		cond.mCompareOp = "=";
 
-        xml_attribute<>* attr;
-        attr = condition->first_attribute("var1");
-        if (attr)   cond.mVar1 = attr->value();
+		xml_attribute<>* attr;
+		attr = condition->first_attribute("var1");
+		if (attr)   cond.mVar1 = attr->value();
 
-        attr = condition->first_attribute("op");
-        if (attr)   cond.mCompareOp = attr->value();
+		attr = condition->first_attribute("op");
+		if (attr)   cond.mCompareOp = attr->value();
 
-        attr = condition->first_attribute("var2");
-        if (attr)   cond.mVar2 = attr->value();
-    
-        mConditions.push_back(cond);
+		attr = condition->first_attribute("var2");
+		if (attr)   cond.mVar2 = attr->value();
+	
+		mConditions.push_back(cond);
 
-        condition = condition->next_sibling("condition");
-    }
+		condition = condition->next_sibling("condition");
+	}
 }
 
 bool Conditional::IsConditionVariable(std::string var)
 {
-    std::vector<Condition>::iterator iter;
-    for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
-    {
-        if (iter->mVar1 == var)     return true;
-    }
-    return false;
+	std::vector<Condition>::iterator iter;
+	for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
+	{
+		if (iter->mVar1 == var)
+			return true;
+	}
+	return false;
 }
 
 bool Conditional::isConditionTrue()
 {
-    std::vector<Condition>::iterator iter;
-    for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
-    {
-        if (!isConditionTrue(&(*iter)))     return false;
-    }
-    return true;
+	std::vector<Condition>::iterator iter;
+	for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
+	{
+		if (!isConditionTrue(&(*iter)))
+			return false;
+	}
+	return true;
 }
 
 bool Conditional::isConditionTrue(Condition* condition)
 {
-    // This is used to hold the proper value of "true" based on the '!' NOT flag
-    bool bTrue = true;
+	// This is used to hold the proper value of "true" based on the '!' NOT flag
+	bool bTrue = true;
 
-    if (condition->mVar1.empty())      return bTrue;
+	if (condition->mVar1.empty())
+		return bTrue;
 
-    if (!condition->mCompareOp.empty() && condition->mCompareOp[0] == '!')
-        bTrue = false;
+	if (!condition->mCompareOp.empty() && condition->mCompareOp[0] == '!')
+		bTrue = false;
 
-    if (condition->mVar2.empty() && condition->mCompareOp != "modified")
-    {
-        if (!DataManager::GetStrValue(condition->mVar1).empty())
-            return bTrue;
+	if (condition->mVar2.empty() && condition->mCompareOp != "modified")
+	{
+		if (!DataManager::GetStrValue(condition->mVar1).empty())
+			return bTrue;
 
-        return !bTrue;
-    }
+		return !bTrue;
+	}
 
-    string var1, var2;
-    if (DataManager::GetValue(condition->mVar1, var1))
-        var1 = condition->mVar1;
-    if (DataManager::GetValue(condition->mVar2, var2))
-        var2 = condition->mVar2;
+	string var1, var2;
+	if (DataManager::GetValue(condition->mVar1, var1))
+		var1 = condition->mVar1;
+	if (DataManager::GetValue(condition->mVar2, var2))
+		var2 = condition->mVar2;
 
-    // This is a special case, we stat the file and that determines our result
-    if (var1 == "fileexists")
-    {
-        struct stat st;
-        if (stat(var2.c_str(), &st) == 0)
-            var2 = var1;
-        else
-            var2 = "FAILED";
-    }
-    if (var1 == "mounted")
-    {
-        if (isMounted(condition->mVar2))
-            var2 = var1;
-        else
-            var2 = "FAILED";
-    }
+	// This is a special case, we stat the file and that determines our result
+	if (var1 == "fileexists")
+	{
+		struct stat st;
+		if (stat(var2.c_str(), &st) == 0)
+			var2 = var1;
+		else
+			var2 = "FAILED";
+	}
+	if (var1 == "mounted")
+	{
+		if (isMounted(condition->mVar2))
+			var2 = var1;
+		else
+			var2 = "FAILED";
+	}
 
-    if (condition->mCompareOp.find('=') != string::npos && var1 == var2)
-        return bTrue;
+	if (condition->mCompareOp.find('=') != string::npos && var1 == var2)
+		return bTrue;
 
-    if (condition->mCompareOp.find('>') != string::npos && (atof(var1.c_str()) > atof(var2.c_str())))
-        return bTrue;
+	if (condition->mCompareOp.find('>') != string::npos && (atof(var1.c_str()) > atof(var2.c_str())))
+		return bTrue;
 
-    if (condition->mCompareOp.find('<') != string::npos && (atof(var1.c_str()) < atof(var2.c_str())))
-        return bTrue;
+	if (condition->mCompareOp.find('<') != string::npos && (atof(var1.c_str()) < atof(var2.c_str())))
+		return bTrue;
 
-    if (condition->mCompareOp == "modified")
-    {
-        // This is a hack to allow areas to reset the default value
-        if (var1.empty())
-        {
-            condition->mLastVal = var1;
-            return !bTrue;
-        }
+	if (condition->mCompareOp == "modified")
+	{
+		// This is a hack to allow areas to reset the default value
+		if (var1.empty())
+		{
+			condition->mLastVal = var1;
+			return !bTrue;
+		}
 
-        if (var1 != condition->mLastVal)
-            return bTrue;
-    }
+		if (var1 != condition->mLastVal)
+			return bTrue;
+	}
 
-    return !bTrue;
+	return !bTrue;
 }
 
 bool Conditional::isConditionValid()
 {
-    return !mConditions.empty();
+	return !mConditions.empty();
 }
 
 void Conditional::NotifyPageSet()
 {
-    std::vector<Condition>::iterator iter;
-    for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
-    {
-        if (iter->mCompareOp == "modified")
-        {
-            string val;
-    
-            // If this fails, val will not be set, which is perfect
-            if (DataManager::GetValue(iter->mVar1, val))
-            {
-                DataManager::SetValue(iter->mVar1, "");
-                DataManager::GetValue(iter->mVar1, val);
-            }
-            iter->mLastVal = val;
-        }
-    }
+	std::vector<Condition>::iterator iter;
+	for (iter = mConditions.begin(); iter != mConditions.end(); iter++)
+	{
+		if (iter->mCompareOp == "modified")
+		{
+			string val;
+	
+			// If this fails, val will not be set, which is perfect
+			if (DataManager::GetValue(iter->mVar1, val))
+			{
+				DataManager::SetValue(iter->mVar1, "");
+				DataManager::GetValue(iter->mVar1, val);
+			}
+			iter->mLastVal = val;
+		}
+	}
 }
 
 bool Conditional::isMounted(string vol)
 {
 	FILE *fp;
-    char tmpOutput[255];
+	char tmpOutput[255];
 
 	if (strcmp(vol.c_str(), "EXTERNAL") == 0)
 		DataManager::GetValue(TW_EXTERNAL_MOUNT, vol);
@@ -184,19 +187,18 @@
 	fp = fopen("/proc/mounts", "rt");
 	while (fgets(tmpOutput,255,fp) != NULL)
 	{
-        char* mnt = tmpOutput;
-        while (*mnt > 32)               mnt++;
-        while (*mnt > 0 && *mnt <= 32)  mnt++;
-        char* pos = mnt;
-	    while (*pos > 32)   pos++;
-        *pos = 0;
-	    if (vol == mnt)
-        {
-            fclose(fp);
-            return true;
-        }
-    }
-    fclose(fp);
-    return false;
+		char* mnt = tmpOutput;
+		while (*mnt > 32)			mnt++;
+		while (*mnt > 0 && *mnt <= 32)	mnt++;
+		char* pos = mnt;
+		while (*pos > 32)   pos++;
+		*pos = 0;
+		if (vol == mnt)
+		{
+			fclose(fp);
+			return true;
+		}
+	}
+	fclose(fp);
+	return false;
 }
-
diff --git a/gui/console.cpp b/gui/console.cpp
index ee3b5e5..517a7c2 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -30,373 +30,374 @@
 
 extern "C" void gui_print(const char *fmt, ...)
 {
-    char buf[512];          // We're going to limit a single request to 512 bytes
+	char buf[512];		// We're going to limit a single request to 512 bytes
 
-    va_list ap;
-    va_start(ap, fmt);
-    vsnprintf(buf, 512, fmt, ap);
-    va_end(ap);
+	va_list ap;
+	va_start(ap, fmt);
+	vsnprintf(buf, 512, fmt, ap);
+	va_end(ap);
 
 	fputs(buf, stdout);
 
-    char *start, *next;
+	char *start, *next;
 
 	if (buf[0] == '\n' && strlen(buf) < 2) {
 		// This prevents the double lines bug seen in the console during zip installs
 		return;
 	}
 
-    for (start = next = buf; *next != '\0'; next++)
-    {
-        if (*next == '\n')
-        {
-            *next = '\0';
-            next++;
+	for (start = next = buf; *next != '\0'; next++)
+	{
+		if (*next == '\n')
+		{
+			*next = '\0';
+			next++;
 
-            std::string line = start;
-            gConsole.push_back(line);
-            start = next;
+			std::string line = start;
+			gConsole.push_back(line);
+			start = next;
 
 			// Handle the normal \n\0 case
-            if (*next == '\0')
+			if (*next == '\0')
 				return;
-        }
-    }
-    std::string line = start;
-    gConsole.push_back(line);
-    return;
+		}
+	}
+	std::string line = start;
+	gConsole.push_back(line);
+	return;
 }
 
 extern "C" void gui_print_overwrite(const char *fmt, ...)
 {
-    char buf[512];          // We're going to limit a single request to 512 bytes
+	char buf[512];		// We're going to limit a single request to 512 bytes
 
-    va_list ap;
-    va_start(ap, fmt);
-    vsnprintf(buf, 512, fmt, ap);
-    va_end(ap);
+	va_list ap;
+	va_start(ap, fmt);
+	vsnprintf(buf, 512, fmt, ap);
+	va_end(ap);
 
 	fputs(buf, stdout);
 
-    // Pop the last line, and we can continue
-    if (!gConsole.empty())   gConsole.pop_back();
+	// Pop the last line, and we can continue
+	if (!gConsole.empty())   gConsole.pop_back();
 
-    char *start, *next;
-    for (start = next = buf; *next != '\0'; next++)
-    {
-        if (*next == '\n')
-        {
-            *next = '\0';
-            next++;
-            
-            std::string line = start;
-            gConsole.push_back(line);
-            start = next;
+	char *start, *next;
+	for (start = next = buf; *next != '\0'; next++)
+	{
+		if (*next == '\n')
+		{
+			*next = '\0';
+			next++;
+			
+			std::string line = start;
+			gConsole.push_back(line);
+			start = next;
 
-            // Handle the normal \n\0 case
-            if (*next == '\0')
+			// Handle the normal \n\0 case
+			if (*next == '\0')
 				return;
-        }
-    }
-    std::string line = start;
-    gConsole.push_back(line);
-    return;
+		}
+	}
+	std::string line = start;
+	gConsole.push_back(line);
+	return;
 }
 
 GUIConsole::GUIConsole(xml_node<>* node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mFont = NULL;
-    mCurrentLine = -1;
-    memset(&mForegroundColor, 255, sizeof(COLOR));
-    memset(&mBackgroundColor, 0, sizeof(COLOR));
-    mBackgroundColor.alpha = 255;
-    memset(&mScrollColor, 0x08, sizeof(COLOR));
-    mScrollColor.alpha = 255;
-    mLastCount = 0;
-    mSlideout = 0;
-    mSlideoutState = hidden;
+	mFont = NULL;
+	mCurrentLine = -1;
+	memset(&mForegroundColor, 255, sizeof(COLOR));
+	memset(&mBackgroundColor, 0, sizeof(COLOR));
+	mBackgroundColor.alpha = 255;
+	memset(&mScrollColor, 0x08, sizeof(COLOR));
+	mScrollColor.alpha = 255;
+	mLastCount = 0;
+	mSlideout = 0;
+	mSlideoutState = hidden;
 
-    mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
+	mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
 
-    if (!node)
-    {
-        mSlideoutX = 0; mSlideoutY = 0; mSlideoutW = 0; mSlideoutH = 0;
-        mConsoleX = 0;  mConsoleY = 0;  mConsoleW = gr_fb_width();  mConsoleH = gr_fb_height();
-    }
-    else
-    {
-        child = node->first_node("font");
-        if (child)
-        {
-            attr = child->first_attribute("resource");
-            if (attr)
-                mFont = PageManager::FindResource(attr->value());
-        }
+	if (!node)
+	{
+		mSlideoutX = 0; mSlideoutY = 0; mSlideoutW = 0; mSlideoutH = 0;
+		mConsoleX = 0;  mConsoleY = 0;  mConsoleW = gr_fb_width();  mConsoleH = gr_fb_height();
+	}
+	else
+	{
+		child = node->first_node("font");
+		if (child)
+		{
+			attr = child->first_attribute("resource");
+			if (attr)
+				mFont = PageManager::FindResource(attr->value());
+		}
 
-        child = node->first_node("color");
-        if (child)
-        {
-            attr = child->first_attribute("foreground");
-            if (attr)
-            {
-                std::string color = attr->value();
-                ConvertStrToColor(color, &mForegroundColor);
-            }
-            attr = child->first_attribute("background");
-            if (attr)
-            {
-                std::string color = attr->value();
-                ConvertStrToColor(color, &mBackgroundColor);
-            }
-            attr = child->first_attribute("scroll");
-            if (attr)
-            {
-                std::string color = attr->value();
-                ConvertStrToColor(color, &mScrollColor);
-            }
-        }
+		child = node->first_node("color");
+		if (child)
+		{
+			attr = child->first_attribute("foreground");
+			if (attr)
+			{
+				std::string color = attr->value();
+				ConvertStrToColor(color, &mForegroundColor);
+			}
+			attr = child->first_attribute("background");
+			if (attr)
+			{
+				std::string color = attr->value();
+				ConvertStrToColor(color, &mBackgroundColor);
+			}
+			attr = child->first_attribute("scroll");
+			if (attr)
+			{
+				std::string color = attr->value();
+				ConvertStrToColor(color, &mScrollColor);
+			}
+		}
 
-        // Load the placement
-        LoadPlacement(node->first_node("placement"), &mConsoleX, &mConsoleY, &mConsoleW, &mConsoleH);
+		// Load the placement
+		LoadPlacement(node->first_node("placement"), &mConsoleX, &mConsoleY, &mConsoleW, &mConsoleH);
 
-        child = node->first_node("slideout");
-        if (child)
-        {
-            mSlideout = 1;
-            LoadPlacement(child, &mSlideoutX, &mSlideoutY);
+		child = node->first_node("slideout");
+		if (child)
+		{
+			mSlideout = 1;
+			LoadPlacement(child, &mSlideoutX, &mSlideoutY);
 
-            attr = child->first_attribute("resource");
-            if (attr)   mSlideoutImage = PageManager::FindResource(attr->value());
+			attr = child->first_attribute("resource");
+			if (attr)   mSlideoutImage = PageManager::FindResource(attr->value());
 
-            if (mSlideoutImage && mSlideoutImage->GetResource())
-            {
-                mSlideoutW = gr_get_width(mSlideoutImage->GetResource());
-                mSlideoutH = gr_get_height(mSlideoutImage->GetResource());
-            }
-        }
-    }
+			if (mSlideoutImage && mSlideoutImage->GetResource())
+			{
+				mSlideoutW = gr_get_width(mSlideoutImage->GetResource());
+				mSlideoutH = gr_get_height(mSlideoutImage->GetResource());
+			}
+		}
+	}
 
-    gr_getFontDetails(mFont, &mFontHeight, NULL);
-    SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
-    SetRenderPos(mConsoleX, mConsoleY);
-    return;
+	gr_getFontDetails(mFont, &mFontHeight, NULL);
+	SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
+	SetRenderPos(mConsoleX, mConsoleY);
+	return;
 }
 
 int GUIConsole::RenderSlideout(void)
 {
-    if (!mSlideoutImage || !mSlideoutImage->GetResource())      return -1;
+	if (!mSlideoutImage || !mSlideoutImage->GetResource())
+		return -1;
 
-    gr_blit(mSlideoutImage->GetResource(), 0, 0, mSlideoutW, mSlideoutH, mSlideoutX, mSlideoutY);
-    return 0;
+	gr_blit(mSlideoutImage->GetResource(), 0, 0, mSlideoutW, mSlideoutH, mSlideoutX, mSlideoutY);
+	return 0;
 }
 
 int GUIConsole::RenderConsole(void)
 {
-    void* fontResource = NULL;
-    if (mFont)  fontResource = mFont->GetResource();
+	void* fontResource = NULL;
+	if (mFont)
+		fontResource = mFont->GetResource();
 
-    // We fill the background
-    gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255);
-    gr_fill(mConsoleX, mConsoleY, mConsoleW, mConsoleH);
+	// We fill the background
+	gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255);
+	gr_fill(mConsoleX, mConsoleY, mConsoleW, mConsoleH);
 
-    gr_color(mScrollColor.red, mScrollColor.green, mScrollColor.blue, mScrollColor.alpha);
-    gr_fill(mConsoleX + (mConsoleW * 9 / 10), mConsoleY, (mConsoleW / 10), mConsoleH);
+	gr_color(mScrollColor.red, mScrollColor.green, mScrollColor.blue, mScrollColor.alpha);
+	gr_fill(mConsoleX + (mConsoleW * 9 / 10), mConsoleY, (mConsoleW / 10), mConsoleH);
 
-    // Render the lines
-    gr_color(mForegroundColor.red, mForegroundColor.green, mForegroundColor.blue, mForegroundColor.alpha);
+	// Render the lines
+	gr_color(mForegroundColor.red, mForegroundColor.green, mForegroundColor.blue, mForegroundColor.alpha);
 
-    // Don't try to continue to render without data
-    mLastCount = gConsole.size();
-    if (mLastCount == 0)        return (mSlideout ? RenderSlideout() : 0);
+	// Don't try to continue to render without data
+	mLastCount = gConsole.size();
+	if (mLastCount == 0)
+		return (mSlideout ? RenderSlideout() : 0);
 
-    // Find the start point
-    int start;
-    int curLine = mCurrentLine;    // Thread-safing (Another thread updates this value)
-    if (curLine == -1)
-    {
-        start = mLastCount - mMaxRows;
-    }
-    else
-    {
-        if (curLine > (int) mLastCount)   curLine = (int) mLastCount;
-        if ((int) mMaxRows > curLine)     curLine = (int) mMaxRows;
-        start = curLine - mMaxRows;
-    }
+	// Find the start point
+	int start;
+	int curLine = mCurrentLine; // Thread-safing (Another thread updates this value)
+	if (curLine == -1)
+	{
+		start = mLastCount - mMaxRows;
+	}
+	else
+	{
+		if (curLine > (int) mLastCount)
+			curLine = (int) mLastCount;
+		if ((int) mMaxRows > curLine)
+			curLine = (int) mMaxRows;
+		start = curLine - mMaxRows;
+	}
 
-    unsigned int line;
-    for (line = 0; line < mMaxRows; line++)
-    {
-        if ((start + (int) line) >= 0 && (start + (int) line) < (int) mLastCount)
-        {
-            gr_textExW(mConsoleX, mStartY + (line * mFontHeight), gConsole[start + line].c_str(), fontResource, mConsoleW + mConsoleX);
-        }
-    }
-    return (mSlideout ? RenderSlideout() : 0);
+	unsigned int line;
+	for (line = 0; line < mMaxRows; line++)
+	{
+		if ((start + (int) line) >= 0 && (start + (int) line) < (int) mLastCount)
+			gr_textExW(mConsoleX, mStartY + (line * mFontHeight), gConsole[start + line].c_str(), fontResource, mConsoleW + mConsoleX);
+	}
+	return (mSlideout ? RenderSlideout() : 0);
 }
 
 int GUIConsole::Render(void)
 {
-    if (mSlideout && mSlideoutState == hidden)
-    {
-        return RenderSlideout();
-    }
-    return RenderConsole();
+	if (mSlideout && mSlideoutState == hidden)
+		return RenderSlideout();
+
+	return RenderConsole();
 }
 
 int GUIConsole::Update(void)
 {
-    if (mSlideout && mSlideoutState != visible)
-    {
-        if (mSlideoutState == hidden)
-            return 0;
+	if (mSlideout && mSlideoutState != visible)
+	{
+		if (mSlideoutState == hidden)
+			return 0;
 
-        if (mSlideoutState == request_hide)
-            mSlideoutState = hidden;
+		if (mSlideoutState == request_hide)
+			mSlideoutState = hidden;
 
-        if (mSlideoutState == request_show)
-            mSlideoutState = visible;
+		if (mSlideoutState == request_show)
+			mSlideoutState = visible;
 
-        // Any time we activate the slider, we reset the position
-        mCurrentLine = -1;
-        return 2;
-    }
+		// Any time we activate the slider, we reset the position
+		mCurrentLine = -1;
+		return 2;
+	}
 
-    if (mCurrentLine == -1 && mLastCount != gConsole.size())
-    {
-        // We can use Render, and return for just a flip
-        Render();
-        return 2;
-    }
-    else if (mLastTouchY >= 0)
-    {
-        // They're still touching, so re-render
-        Render();
-        mLastTouchY = -1;
-        return 2;
-    }
-    return 0;
+	if (mCurrentLine == -1 && mLastCount != gConsole.size())
+	{
+		// We can use Render, and return for just a flip
+		Render();
+		return 2;
+	}
+	else if (mLastTouchY >= 0)
+	{
+		// They're still touching, so re-render
+		Render();
+		mLastTouchY = -1;
+		return 2;
+	}
+	return 0;
 }
 
 int GUIConsole::SetRenderPos(int x, int y, int w, int h)
 {
-    // Adjust the stub position accordingly
-    mSlideoutX += (x - mConsoleX);
-    mSlideoutY += (y - mConsoleY);
+	// Adjust the stub position accordingly
+	mSlideoutX += (x - mConsoleX);
+	mSlideoutY += (y - mConsoleY);
 
-    mConsoleX = x;
-    mConsoleY = y;
-    if (w || h)
-    {
-        mConsoleW = w;
-        mConsoleH = h;
-    }
+	mConsoleX = x;
+	mConsoleY = y;
+	if (w || h)
+	{
+		mConsoleW = w;
+		mConsoleH = h;
+	}
 
-    // Calculate the max rows
-    mMaxRows = mConsoleH / mFontHeight;
+	// Calculate the max rows
+	mMaxRows = mConsoleH / mFontHeight;
 
-    // Adjust so we always fit to bottom
-    mStartY = mConsoleY + (mConsoleH % mFontHeight);
-    return 0;
+	// Adjust so we always fit to bottom
+	mStartY = mConsoleY + (mConsoleH % mFontHeight);
+	return 0;
 }
 
 // IsInRegion - Checks if the request is handled by this object
 //  Return 0 if this object handles the request, 1 if not
 int GUIConsole::IsInRegion(int x, int y)
 {
-    if (mSlideout)
-    {
-        // Check if they tapped the slideout button
-        if (x >= mSlideoutX && x <= mSlideoutX + mSlideoutW && y >= mSlideoutY && y < mSlideoutY + mSlideoutH)
-            return 1;
+	if (mSlideout)
+	{
+		// Check if they tapped the slideout button
+		if (x >= mSlideoutX && x <= mSlideoutX + mSlideoutW && y >= mSlideoutY && y < mSlideoutY + mSlideoutH)
+			return 1;
 
-        // If we're only rendering the slideout, bail now
-        if (mSlideoutState == hidden)
-            return 0;
-    }
+		// If we're only rendering the slideout, bail now
+		if (mSlideoutState == hidden)
+			return 0;
+	}
 
-    return (x < mConsoleX || x > mConsoleX + mConsoleW || y < mConsoleY || y > mConsoleY + mConsoleH) ? 0 : 1;
+	return (x < mConsoleX || x > mConsoleX + mConsoleW || y < mConsoleY || y > mConsoleY + mConsoleH) ? 0 : 1;
 }
 
 // NotifyTouch - Notify of a touch event
 //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
 int GUIConsole::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    if (mSlideout && mSlideoutState == hidden)
-    {
-        if (state == TOUCH_START)
-        {
-            mSlideoutState = request_show;
-            return 1;
-        }
-    }
-    else if (mSlideout && mSlideoutState == visible)
-    {
-        // Are we sliding it back in?
-        if (state == TOUCH_START && x > mSlideoutX && x < (mSlideoutX + mSlideoutW) && y > mSlideoutY && y < (mSlideoutY + mSlideoutH))
-        {
-            mSlideoutState = request_hide;
-            return 1;
-        }
-    }
+	if (mSlideout && mSlideoutState == hidden)
+	{
+		if (state == TOUCH_START)
+		{
+			mSlideoutState = request_show;
+			return 1;
+		}
+	}
+	else if (mSlideout && mSlideoutState == visible)
+	{
+		// Are we sliding it back in?
+		if (state == TOUCH_START && x > mSlideoutX && x < (mSlideoutX + mSlideoutW) && y > mSlideoutY && y < (mSlideoutY + mSlideoutH))
+		{
+			mSlideoutState = request_hide;
+			return 1;
+		}
+	}
 
-    // If we don't have enough lines to scroll, throw this away.
-    if (mLastCount < mMaxRows)   return 1;
+	// If we don't have enough lines to scroll, throw this away.
+	if (mLastCount < mMaxRows)   return 1;
 
-    // We are scrolling!!!
-    switch (state)
-    {
-    case TOUCH_START:
-        mLastTouchX = x;
-        mLastTouchY = y;
-        if ((x - mConsoleX) > ((9 * mConsoleW) / 10))
-            mSlideMultiplier = 10;
-        else
-            mSlideMultiplier = 1;
-        break;
+	// We are scrolling!!!
+	switch (state)
+	{
+	case TOUCH_START:
+		mLastTouchX = x;
+		mLastTouchY = y;
+		if ((x - mConsoleX) > ((9 * mConsoleW) / 10))
+			mSlideMultiplier = 10;
+		else
+			mSlideMultiplier = 1;
+		break;
 
-    case TOUCH_DRAG:
-        // This handles tapping
-        if (x == mLastTouchX && y == mLastTouchY)   break;
-        mLastTouchX = -1;
+	case TOUCH_DRAG:
+		// This handles tapping
+		if (x == mLastTouchX && y == mLastTouchY)   break;
+		mLastTouchX = -1;
 
-        if (y > mLastTouchY + 5)
-        {
-            mLastTouchY = y;
-            if (mCurrentLine == -1)
-                mCurrentLine = mLastCount - 1;
-            else if (mCurrentLine > mSlideMultiplier)
-                mCurrentLine -= mSlideMultiplier;
-            else
-                mCurrentLine = mMaxRows;
+		if (y > mLastTouchY + 5)
+		{
+			mLastTouchY = y;
+			if (mCurrentLine == -1)
+				mCurrentLine = mLastCount - 1;
+			else if (mCurrentLine > mSlideMultiplier)
+				mCurrentLine -= mSlideMultiplier;
+			else
+				mCurrentLine = mMaxRows;
 
-            if (mCurrentLine < (int) mMaxRows)
-                mCurrentLine = mMaxRows;
-        }
-        else if (y < mLastTouchY - 5)
-        {
-            mLastTouchY = y;
-            if (mCurrentLine >= 0)
-            {
-                mCurrentLine += mSlideMultiplier;
-                if (mCurrentLine >= (int) mLastCount)
-                    mCurrentLine = -1;
-            }
-        }
-        break;
+			if (mCurrentLine < (int) mMaxRows)
+				mCurrentLine = mMaxRows;
+		}
+		else if (y < mLastTouchY - 5)
+		{
+			mLastTouchY = y;
+			if (mCurrentLine >= 0)
+			{
+				mCurrentLine += mSlideMultiplier;
+				if (mCurrentLine >= (int) mLastCount)
+					mCurrentLine = -1;
+			}
+		}
+		break;
 
-    case TOUCH_RELEASE:
-        // On a tap, we jump to the tail
-        if (mLastTouchX >= 0)
-            mCurrentLine = -1;
+	case TOUCH_RELEASE:
+		// On a tap, we jump to the tail
+		if (mLastTouchX >= 0)
+			mCurrentLine = -1;
 
-        mLastTouchY = -1;
+		mLastTouchY = -1;
 	case TOUCH_REPEAT:
 	case TOUCH_HOLD:
-        break;
-    }
-    return 0;
+		break;
+	}
+	return 0;
 }
-
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 539bba0..0f8d903 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -198,12 +198,12 @@
 
 		attr = child->first_attribute("highlightcolor");
 		memset(&mFontHighlightColor, 0, sizeof(COLOR));
-        if (attr)
-        {
-            std::string color = attr->value();
+		if (attr)
+		{
+			std::string color = attr->value();
 			ConvertStrToColor(color, &mFontHighlightColor);
 			hasFontHighlightColor = true;
-        }
+		}
 	}
 
 	// Load the separator if it exists
@@ -408,11 +408,10 @@
 	if (updateFileList) {
 		string value;
 		DataManager::GetValue(mPathVar, value);
-		if (GetFileList(value) == 0) {
+		if (GetFileList(value) == 0)
 			updateFileList = false;
-		} else {
+		else
 			return 0;
-		}
 	}
 
 	// This tells us how many lines we can actually render
@@ -652,7 +651,9 @@
 int GUIFileSelector::GetSelection(int x, int y)
 {
 	// We only care about y position
-	if (y < mRenderY || y - mRenderY <= mHeaderH || y - mRenderY > mRenderH) return -1;
+	if (y < mRenderY || y - mRenderY <= mHeaderH || y - mRenderY > mRenderH)
+		return -1;
+
 	return (y - mRenderY - mHeaderH);
 }
 
@@ -674,7 +675,6 @@
 		startY = lastY = last2Y = y;
 		scrollingSpeed = 0;
 		break;
-
 	case TOUCH_DRAG:
 		// Check if we dragged out of the selection window
 		if (GetSelection(x, y) == -1) {
diff --git a/gui/fill.cpp b/gui/fill.cpp
index 901eee1..ad1f4e0 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -27,31 +27,31 @@
 
 GUIFill::GUIFill(xml_node<>* node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    if (!node)
-        return;
+	if (!node)
+		return;
 
-    attr = node->first_attribute("color");
-    if (!attr) {
+	attr = node->first_attribute("color");
+	if (!attr) {
 		LOGERR("No color specified for fill\n");
-        return;
+		return;
 	}
 
-    std::string color = attr->value();
-    ConvertStrToColor(color, &mColor);
+	std::string color = attr->value();
+	ConvertStrToColor(color, &mColor);
 
-    // Load the placement
-    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH);
+	// Load the placement
+	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH);
 
-    return;
+	return;
 }
 
 int GUIFill::Render(void)
 {
-    gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
-    gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
-    return 0;
+	gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
+	gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
+	return 0;
 }
 
diff --git a/gui/gui.cpp b/gui/gui.cpp
index 8755689..821c7f5 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -69,685 +69,659 @@
 
 static int gRecorder = -1;
 
-extern "C" void gr_write_frame_to_file (int fd);
+extern "C" void gr_write_frame_to_file(int fd);
 
-void
-flip (void)
+void flip(void)
 {
-  if (gRecorder != -1)
+	if (gRecorder != -1)
 	{
-	  timespec time;
-	  clock_gettime (CLOCK_MONOTONIC, &time);
-	  write (gRecorder, &time, sizeof (timespec));
-	  gr_write_frame_to_file (gRecorder);
+		timespec time;
+		clock_gettime(CLOCK_MONOTONIC, &time);
+		write(gRecorder, &time, sizeof(timespec));
+		gr_write_frame_to_file(gRecorder);
 	}
-  gr_flip ();
-  return;
+	gr_flip();
 }
 
-void
-rapidxml::parse_error_handler (const char *what, void *where)
+void rapidxml::parse_error_handler(const char *what, void *where)
 {
-  fprintf (stderr, "Parser error: %s\n", what);
-  fprintf (stderr, "  Start of string: %s\n", (char *) where);
-  LOGERR("Error parsing XML file.\n");
-  //abort ();
+	fprintf(stderr, "Parser error: %s\n", what);
+	fprintf(stderr, "  Start of string: %s\n",(char *) where);
+	LOGERR("Error parsing XML file.\n");
+	//abort();
 }
 
-static void
-curtainSet ()
+static void curtainSet()
 {
-  gr_color (0, 0, 0, 255);
-  gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
-  gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain), gr_get_height (gCurtain),
-		   0, 0);
-  gr_flip ();
-  return;
+	gr_color(0, 0, 0, 255);
+	gr_fill(0, 0, gr_fb_width(), gr_fb_height());
+	gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
+	gr_flip();
 }
 
-static void
-curtainRaise (gr_surface surface)
+static void curtainRaise(gr_surface surface)
 {
-  int sy = 0;
-  int h = gr_get_height (gCurtain) - 1;
-  int w = gr_get_width (gCurtain);
-  int fy = 1;
+	int sy = 0;
+	int h = gr_get_height(gCurtain) - 1;
+	int w = gr_get_width(gCurtain);
+	int fy = 1;
 
-  int msw = gr_get_width (surface);
-  int msh = gr_get_height (surface);
-  int CURTAIN_RATE = msh / 30;
+	int msw = gr_get_width(surface);
+	int msh = gr_get_height(surface);
+	int CURTAIN_RATE = msh / 30;
 
-  if (gNoAnimation == 0)
+	if (gNoAnimation == 0)
 	{
-	  for (; h > 0; h -= CURTAIN_RATE, sy += CURTAIN_RATE, fy += CURTAIN_RATE)
+		for (; h > 0; h -= CURTAIN_RATE, sy += CURTAIN_RATE, fy += CURTAIN_RATE)
 		{
-		  gr_blit (surface, 0, 0, msw, msh, 0, 0);
-		  gr_blit (gCurtain, 0, sy, w, h, 0, 0);
-		  gr_flip ();
+			gr_blit(surface, 0, 0, msw, msh, 0, 0);
+			gr_blit(gCurtain, 0, sy, w, h, 0, 0);
+			gr_flip();
 		}
 	}
-  gr_blit (surface, 0, 0, msw, msh, 0, 0);
-  flip ();
-  return;
+	gr_blit(surface, 0, 0, msw, msh, 0, 0);
+	flip();
 }
 
-void
-curtainClose ()
+void curtainClose()
 {
 #if 0
-  int w = gr_get_width (gCurtain);
-  int h = 1;
-  int sy = gr_get_height (gCurtain) - 1;
-  int fbh = gr_fb_height ();
-  int CURTAIN_RATE = fbh / 30;
+	int w = gr_get_width(gCurtain);
+	int h = 1;
+	int sy = gr_get_height(gCurtain) - 1;
+	int fbh = gr_fb_height();
+	int CURTAIN_RATE = fbh / 30;
 
-  if (gNoAnimation == 0)
+	if (gNoAnimation == 0)
 	{
-	  for (; h < fbh; h += CURTAIN_RATE, sy -= CURTAIN_RATE)
+		for (; h < fbh; h += CURTAIN_RATE, sy -= CURTAIN_RATE)
 		{
-		  gr_blit (gCurtain, 0, sy, w, h, 0, 0);
-		  gr_flip ();
+			gr_blit(gCurtain, 0, sy, w, h, 0, 0);
+			gr_flip();
 		}
-	  gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain),
-			   gr_get_height (gCurtain), 0, 0);
-	  gr_flip ();
+		gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain),
+		gr_get_height(gCurtain), 0, 0);
+		gr_flip();
 
-	  if (gRecorder != -1)
-		close (gRecorder);
+		if (gRecorder != -1)
+			close(gRecorder);
 
-	  int fade;
-	  for (fade = 16; fade < 255; fade += CURTAIN_FADE)
+		int fade;
+		for (fade = 16; fade < 255; fade += CURTAIN_FADE)
 		{
-		  gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain),
-				   gr_get_height (gCurtain), 0, 0);
-		  gr_color (0, 0, 0, fade);
-		  gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
-		  gr_flip ();
+			gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain),
+			gr_get_height(gCurtain), 0, 0);
+			gr_color(0, 0, 0, fade);
+			gr_fill(0, 0, gr_fb_width(), gr_fb_height());
+			gr_flip();
 		}
-	  gr_color (0, 0, 0, 255);
-	  gr_fill (0, 0, gr_fb_width (), gr_fb_height ());
-	  gr_flip ();
+		gr_color(0, 0, 0, 255);
+		gr_fill(0, 0, gr_fb_width(), gr_fb_height());
+		gr_flip();
 	}
 #else
-  gr_blit (gCurtain, 0, 0, gr_get_width (gCurtain), gr_get_height (gCurtain),
-		   0, 0);
-  gr_flip ();
+	gr_blit(gCurtain, 0, 0, gr_get_width(gCurtain), gr_get_height(gCurtain), 0, 0);
+	gr_flip();
 #endif
-  return;
 }
 
-static void *
-input_thread (void *cookie)
+static void * input_thread(void *cookie)
 {
-  int drag = 0;
-  static int touch_and_hold = 0, dontwait = 0, touch_repeat = 0, x = 0, y =
-	0, lshift = 0, rshift = 0, key_repeat = 0;
-  static struct timeval touchStart;
-  HardwareKeyboard kb;
-  string seconds;
+	int drag = 0;
+	static int touch_and_hold = 0, dontwait = 0;
+	static int touch_repeat = 0, key_repeat = 0;
+	static int x = 0, y = 0;
+	static int lshift = 0, rshift = 0;
+	static struct timeval touchStart;
+	HardwareKeyboard kb;
+	string seconds;
 
-  //start screen timeout threads
-  blankTimer.setTimerThread();
-  DataManager::GetValue("tw_screen_timeout_secs", seconds);
-  blankTimer.setTime(atoi(seconds.c_str()));
+	//start screen timeout threads
+	blankTimer.setTimerThread();
+	DataManager::GetValue("tw_screen_timeout_secs", seconds);
+	blankTimer.setTime(atoi(seconds.c_str()));
 
-  for (;;)
+	for (;;)
 	{
+		// wait for the next event
+		struct input_event ev;
+		int state = 0, ret = 0;
 
-	  // wait for the next event
-	  struct input_event ev;
-	  int state = 0, ret = 0;
+		ret = ev_get(&ev, dontwait);
 
-	  ret = ev_get (&ev, dontwait);
-
-	  if (ret < 0)
+		if (ret < 0)
 		{
-		  struct timeval curTime;
-		  gettimeofday (&curTime, NULL);
-		  long mtime, seconds, useconds;
+			struct timeval curTime;
+			gettimeofday(&curTime, NULL);
+			long mtime, seconds, useconds;
 
-		  seconds = curTime.tv_sec - touchStart.tv_sec;
-		  useconds = curTime.tv_usec - touchStart.tv_usec;
+			seconds = curTime.tv_sec - touchStart.tv_sec;
+			useconds = curTime.tv_usec - touchStart.tv_usec;
 
-		  mtime = ((seconds) * 1000 + useconds / 1000.0) + 0.5;
-		  if (touch_and_hold && mtime > 500)
+			mtime = ((seconds) * 1000 + useconds / 1000.0) + 0.5;
+			if (touch_and_hold && mtime > 500)
 			{
-			  touch_and_hold = 0;
-			  touch_repeat = 1;
-			  gettimeofday (&touchStart, NULL);
+				touch_and_hold = 0;
+				touch_repeat = 1;
+				gettimeofday(&touchStart, NULL);
 #ifdef _EVENT_LOGGING
-			  LOGERR("TOUCH_HOLD: %d,%d\n", x, y);
+				LOGERR("TOUCH_HOLD: %d,%d\n", x, y);
 #endif
-			  PageManager::NotifyTouch (TOUCH_HOLD, x, y);
-                          blankTimer.resetTimerAndUnblank();
+				PageManager::NotifyTouch(TOUCH_HOLD, x, y);
+				blankTimer.resetTimerAndUnblank();
 			}
-		  else if (touch_repeat && mtime > 100)
+			else if (touch_repeat && mtime > 100)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGERR("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);
-                          blankTimer.resetTimerAndUnblank();
+				gettimeofday(&touchStart, NULL);
+				PageManager::NotifyTouch(TOUCH_REPEAT, x, y);
+				blankTimer.resetTimerAndUnblank();
 			}
-		  else if (key_repeat == 1 && mtime > 500)
+			else if (key_repeat == 1 && mtime > 500)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGERR("KEY_HOLD: %d,%d\n", x, y);
+				LOGERR("KEY_HOLD: %d,%d\n", x, y);
 #endif
-			  gettimeofday (&touchStart, NULL);
-			  key_repeat = 2;
-			  kb.KeyRepeat ();
-                          blankTimer.resetTimerAndUnblank();
+				gettimeofday(&touchStart, NULL);
+				key_repeat = 2;
+				kb.KeyRepeat();
+				blankTimer.resetTimerAndUnblank();
 			}
-		  else if (key_repeat == 2 && mtime > 100)
+			else if (key_repeat == 2 && mtime > 100)
 			{
 #ifdef _EVENT_LOGGING
-			  LOGERR("KEY_REPEAT: %d,%d\n", x, y);
+				LOGERR("KEY_REPEAT: %d,%d\n", x, y);
 #endif
-			  gettimeofday (&touchStart, NULL);
-			  kb.KeyRepeat ();
-                          blankTimer.resetTimerAndUnblank();
+				gettimeofday(&touchStart, NULL);
+				kb.KeyRepeat();
+				blankTimer.resetTimerAndUnblank();
 			}
 		}
-	  else if (ev.type == EV_ABS)
+		else if (ev.type == EV_ABS)
 		{
 
-		  x = ev.value >> 16;
-		  y = ev.value & 0xFFFF;
+			x = ev.value >> 16;
+			y = ev.value & 0xFFFF;
 
-		  if (ev.code == 0)
+			if (ev.code == 0)
 			{
-			  if (state == 0)
+				if (state == 0)
 				{
 #ifdef _EVENT_LOGGING
-				  LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
+					LOGERR("TOUCH_RELEASE: %d,%d\n", x, y);
 #endif
-				  PageManager::NotifyTouch (TOUCH_RELEASE, x, y);
-				  blankTimer.resetTimerAndUnblank();
-				  touch_and_hold = 0;
-				  touch_repeat = 0;
-				  if (!key_repeat)
-					dontwait = 0;
+					PageManager::NotifyTouch(TOUCH_RELEASE, x, y);
+					blankTimer.resetTimerAndUnblank();
+					touch_and_hold = 0;
+					touch_repeat = 0;
+					if (!key_repeat)
+						dontwait = 0;
 				}
-			  state = 0;
-			  drag = 0;
+				state = 0;
+				drag = 0;
 			}
-		  else
+			else
 			{
-			  if (!drag)
+				if (!drag)
 				{
 #ifdef _EVENT_LOGGING
-				  LOGERR("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;
-				  drag = 1;
-				  touch_and_hold = 1;
-				  dontwait = 1;
-				  key_repeat = 0;
-				  gettimeofday (&touchStart, NULL);
-				  blankTimer.resetTimerAndUnblank();
+					if (PageManager::NotifyTouch(TOUCH_START, x, y) > 0)
+						state = 1;
+					drag = 1;
+					touch_and_hold = 1;
+					dontwait = 1;
+					key_repeat = 0;
+					gettimeofday(&touchStart, NULL);
+					blankTimer.resetTimerAndUnblank();
 				}
-			  else
+				else
 				{
-				  if (state == 0)
+					if (state == 0)
 					{
 #ifdef _EVENT_LOGGING
-					  LOGERR("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;
-					  key_repeat = 0;
-					  blankTimer.resetTimerAndUnblank();
+						if (PageManager::NotifyTouch(TOUCH_DRAG, x, y) > 0)
+							state = 1;
+						key_repeat = 0;
+						blankTimer.resetTimerAndUnblank();
 					}
 				}
 			}
 		}
-	  else if (ev.type == EV_KEY)
+		else if (ev.type == EV_KEY)
 		{
-		  // Handle key-press here
+			// Handle key-press here
 #ifdef _EVENT_LOGGING
-		  LOGERR("TOUCH_KEY: %d\n", ev.code);
+			LOGERR("TOUCH_KEY: %d\n", ev.code);
 #endif
-		  if (ev.value != 0)
+			if (ev.value != 0)
 			{
-			  // This is a key press
-			  if (kb.KeyDown (ev.code))
+				// This is a key press
+				if (kb.KeyDown(ev.code))
 				{
-				  key_repeat = 1;
-				  touch_and_hold = 0;
-				  touch_repeat = 0;
-				  dontwait = 1;
-				  gettimeofday (&touchStart, NULL);
-				  blankTimer.resetTimerAndUnblank();
+					key_repeat = 1;
+					touch_and_hold = 0;
+					touch_repeat = 0;
+					dontwait = 1;
+					gettimeofday(&touchStart, NULL);
+					blankTimer.resetTimerAndUnblank();
 				}
-			  else
+				else
 				{
-				  key_repeat = 0;
-				  touch_and_hold = 0;
-				  touch_repeat = 0;
-				  dontwait = 0;
-				  blankTimer.resetTimerAndUnblank();
+					key_repeat = 0;
+					touch_and_hold = 0;
+					touch_repeat = 0;
+					dontwait = 0;
+					blankTimer.resetTimerAndUnblank();
 				}
 			}
-		  else
+			else
 			{
-			  // This is a key release
-			  kb.KeyUp (ev.code);
-			  key_repeat = 0;
-			  touch_and_hold = 0;
-			  touch_repeat = 0;
-			  dontwait = 0;
-                          blankTimer.resetTimerAndUnblank();
+				// This is a key release
+				kb.KeyUp(ev.code);
+				key_repeat = 0;
+				touch_and_hold = 0;
+				touch_repeat = 0;
+				dontwait = 0;
+				blankTimer.resetTimerAndUnblank();
 			}
 		}
 	}
-  return NULL;
+	return NULL;
 }
 
 // This special function will return immediately the first time, but then
 // always returns 1/30th of a second (or immediately if called later) from
 // the last time it was called
-static void
-loopTimer (void)
+static void loopTimer(void)
 {
-  static timespec lastCall;
-  static int initialized = 0;
+	static timespec lastCall;
+	static int initialized = 0;
 
-  if (!initialized)
+	if (!initialized)
 	{
-	  clock_gettime (CLOCK_MONOTONIC, &lastCall);
-	  initialized = 1;
-	  return;
+		clock_gettime(CLOCK_MONOTONIC, &lastCall);
+		initialized = 1;
+		return;
 	}
 
-  do
+	do
 	{
-	  timespec curTime;
-	  clock_gettime (CLOCK_MONOTONIC, &curTime);
+		timespec curTime;
+		clock_gettime(CLOCK_MONOTONIC, &curTime);
 
-	  timespec diff = TWFunc::timespec_diff (lastCall, curTime);
+		timespec diff = TWFunc::timespec_diff(lastCall, curTime);
 
-	  // This is really 30 times per second
-	  if (diff.tv_sec || diff.tv_nsec > 33333333)
+		// This is really 30 times per second
+		if (diff.tv_sec || diff.tv_nsec > 33333333)
 		{
-		  lastCall = curTime;
-		  return;
+			lastCall = curTime;
+			return;
 		}
 
-	  // We need to sleep some period time microseconds
-	  unsigned int sleepTime = 33333 - (diff.tv_nsec / 1000);
-	  usleep (sleepTime);
-	}
-  while (1);
-  return;
+		// We need to sleep some period time microseconds
+		unsigned int sleepTime = 33333 -(diff.tv_nsec / 1000);
+		usleep(sleepTime);
+	} while (1);
 }
 
-static int
-runPages (void)
+static int runPages(void)
 {
-  // Raise the curtain
-  if (gCurtain != NULL)
+	// Raise the curtain
+	if (gCurtain != NULL)
 	{
-	  gr_surface surface;
+		gr_surface surface;
 
-	  PageManager::Render ();
-	  gr_get_surface (&surface);
-	  curtainRaise (surface);
-	  gr_free_surface (surface);
+		PageManager::Render();
+		gr_get_surface(&surface);
+		curtainRaise(surface);
+		gr_free_surface(surface);
 	}
 
-  gGuiRunning = 1;
+	gGuiRunning = 1;
 
-  DataManager::SetValue ("tw_loaded", 1);
+	DataManager::SetValue("tw_loaded", 1);
 
-  for (;;)
+	for (;;)
 	{
-	  loopTimer ();
+		loopTimer();
 
-	  if (!gForceRender)
+		if (!gForceRender)
 		{
-		  int ret;
+			int ret;
 
-		  ret = PageManager::Update ();
-		  if (ret > 1)
-			PageManager::Render ();
+			ret = PageManager::Update();
+			if (ret > 1)
+				PageManager::Render();
 
-		  if (ret > 0)
-			flip ();
+			if (ret > 0)
+				flip();
 		}
-	  else
+		else
 		{
-		  pthread_mutex_lock(&gForceRendermutex);
-		  gForceRender = 0;
-		  pthread_mutex_unlock(&gForceRendermutex);
-		  PageManager::Render ();
-		  flip ();
+			pthread_mutex_lock(&gForceRendermutex);
+			gForceRender = 0;
+			pthread_mutex_unlock(&gForceRendermutex);
+			PageManager::Render();
+			flip();
 		}
+
 		if (DataManager::GetIntValue("tw_gui_done") != 0)
+			break;
+	}
+
+	gGuiRunning = 0;
+	return 0;
+}
+
+static int runPage(const char *page_name)
+{
+	gui_changePage(page_name);
+
+	// Raise the curtain
+	if (gCurtain != NULL)
+	{
+		gr_surface surface;
+
+		PageManager::Render();
+		gr_get_surface(&surface);
+		curtainRaise(surface);
+		gr_free_surface(surface);
+	}
+
+	gGuiRunning = 1;
+
+	DataManager::SetValue("tw_loaded", 1);
+
+	for (;;)
+	{
+		loopTimer();
+
+		if (!gForceRender)
 		{
+			int ret;
+
+			ret = PageManager::Update();
+			if (ret > 1)
+				PageManager::Render();
+
+			if (ret > 0)
+				flip();
+		}
+		else
+		{
+			pthread_mutex_lock(&gForceRendermutex);
+			gForceRender = 0;
+			pthread_mutex_unlock(&gForceRendermutex);
+			PageManager::Render();
+			flip();
+		}
+		if (DataManager::GetIntValue("tw_page_done") != 0)
+		{
+			gui_changePage("main");
 			break;
 		}
 	}
 
-  gGuiRunning = 0;
-  return 0;
+	gGuiRunning = 0;
+	return 0;
 }
 
-static int
-runPage (const char *page_name)
+int gui_forceRender(void)
 {
-  gui_changePage (page_name);
+	pthread_mutex_lock(&gForceRendermutex);
+	gForceRender = 1;
+	pthread_mutex_unlock(&gForceRendermutex);
+	return 0;
+}
 
-  // Raise the curtain
-  if (gCurtain != NULL)
+int gui_changePage(std::string newPage)
+{
+	LOGINFO("Set page: '%s'\n", newPage.c_str());
+	PageManager::ChangePage(newPage);
+	pthread_mutex_lock(&gForceRendermutex);
+	gForceRender = 1;
+	pthread_mutex_unlock(&gForceRendermutex);
+	return 0;
+}
+
+int gui_changeOverlay(std::string overlay)
+{
+	PageManager::ChangeOverlay(overlay);
+	pthread_mutex_lock(&gForceRendermutex);
+	gForceRender = 1;
+	pthread_mutex_unlock(&gForceRendermutex);
+	return 0;
+}
+
+int gui_changePackage(std::string newPackage)
+{
+	PageManager::SelectPackage(newPackage);
+	pthread_mutex_lock(&gForceRendermutex);
+	gForceRender = 1;
+	pthread_mutex_unlock(&gForceRendermutex);
+	return 0;
+}
+
+std::string gui_parse_text(string inText)
+{
+	// Copied from std::string GUIText::parseText(void)
+	// This function parses text for DataManager values encompassed by %value% in the XML
+	static int counter = 0;
+	std::string str = inText;
+	size_t pos = 0;
+	size_t next = 0, end = 0;
+
+	while (1)
 	{
-	  gr_surface surface;
+		next = str.find('%', pos);
+		if (next == std::string::npos)
+			return str;
 
-	  PageManager::Render ();
-	  gr_get_surface (&surface);
-	  curtainRaise (surface);
-	  gr_free_surface (surface);
-	}
+		end = str.find('%', next + 1);
+		if (end == std::string::npos)
+			return str;
 
-  gGuiRunning = 1;
+		// We have a block of data
+		std::string var = str.substr(next + 1,(end - next) - 1);
+		str.erase(next,(end - next) + 1);
 
-  DataManager::SetValue ("tw_loaded", 1);
-
-  for (;;)
-	{
-	  loopTimer ();
-
-	  if (!gForceRender)
+		if (next + 1 == end)
+			str.insert(next, 1, '%');
+		else
 		{
-		  int ret;
-
-		  ret = PageManager::Update ();
-		  if (ret > 1)
-			PageManager::Render ();
-
-		  if (ret > 0)
-			flip ();
-		}
-	  else
-		{
-		  pthread_mutex_lock(&gForceRendermutex);
-		  gForceRender = 0;
-		  pthread_mutex_unlock(&gForceRendermutex);
-		  PageManager::Render ();
-		  flip ();
-		}
-	  if (DataManager::GetIntValue ("tw_page_done") != 0)
-		{
-		  gui_changePage ("main");
-		  break;
-		}
-	}
-
-  gGuiRunning = 0;
-  return 0;
-}
-
-int
-gui_forceRender (void)
-{
-  pthread_mutex_lock(&gForceRendermutex);
-  gForceRender = 1;
-  pthread_mutex_unlock(&gForceRendermutex);
-  return 0;
-}
-
-int
-gui_changePage (std::string newPage)
-{
-  LOGINFO("Set page: '%s'\n", newPage.c_str ());
-  PageManager::ChangePage (newPage);
-  pthread_mutex_lock(&gForceRendermutex);
-  gForceRender = 1;
-  pthread_mutex_unlock(&gForceRendermutex);
-  return 0;
-}
-
-int
-gui_changeOverlay (std::string overlay)
-{
-  PageManager::ChangeOverlay (overlay);
-  pthread_mutex_lock(&gForceRendermutex);
-  gForceRender = 1;
-  pthread_mutex_unlock(&gForceRendermutex);
-  return 0;
-}
-
-int
-gui_changePackage (std::string newPackage)
-{
-  PageManager::SelectPackage (newPackage);
-  pthread_mutex_lock(&gForceRendermutex);
-  gForceRender = 1;
-  pthread_mutex_unlock(&gForceRendermutex);
-  return 0;
-}
-
-std::string gui_parse_text (string inText)
-{
-  // Copied from std::string GUIText::parseText(void)
-  // This function parses text for DataManager values encompassed by %value% in the XML
-  static int counter = 0;
-  std::string str = inText;
-  size_t pos = 0;
-  size_t next = 0, end = 0;
-
-  while (1)
-	{
-	  next = str.find ('%', pos);
-	  if (next == std::string::npos)
-		return str;
-	  end = str.find ('%', next + 1);
-	  if (end == std::string::npos)
-		return str;
-
-	  // We have a block of data
-	  std::string var = str.substr (next + 1, (end - next) - 1);
-	  str.erase (next, (end - next) + 1);
-
-	  if (next + 1 == end)
-		{
-		  str.insert (next, 1, '%');
-		}
-	  else
-		{
-		  std::string value;
-		  if (DataManager::GetValue (var, value) == 0)
-			str.insert (next, value);
+			std::string value;
+			if (DataManager::GetValue(var, value) == 0)
+				str.insert(next, value);
 		}
 
-	  pos = next + 1;
+		pos = next + 1;
 	}
 }
 
-extern "C" int
-gui_init ()
+extern "C" int gui_init(void)
 {
-  int fd;
+	int fd;
 
-  gr_init ();
+	gr_init();
 
-  if (res_create_surface ("/res/images/curtain.jpg", &gCurtain))
+	if (res_create_surface("/res/images/curtain.jpg", &gCurtain))
 	{
-	  printf
+		printf
 		("Unable to locate '/res/images/curtain.jpg'\nDid you set a DEVICE_RESOLUTION in your config files?\n");
-	  return -1;
+		return -1;
 	}
 
-  curtainSet ();
+	curtainSet();
 
-  ev_init ();
-  return 0;
+	ev_init();
+	return 0;
 }
 
-extern "C" int
-gui_loadResources ()
+extern "C" int gui_loadResources(void)
 {
-//    unlink("/sdcard/video.last");
-//    rename("/sdcard/video.bin", "/sdcard/video.last");
-//    gRecorder = open("/sdcard/video.bin", O_CREAT | O_WRONLY);
+	//    unlink("/sdcard/video.last");
+	//    rename("/sdcard/video.bin", "/sdcard/video.last");
+	//    gRecorder = open("/sdcard/video.bin", O_CREAT | O_WRONLY);
 
-  int check = 0;
-  DataManager::GetValue (TW_IS_ENCRYPTED, check);
-  if (check)
+	int check = 0;
+	DataManager::GetValue(TW_IS_ENCRYPTED, check);
+	if (check)
 	{
-	  if (PageManager::LoadPackage ("TWRP", "/res/ui.xml", "decrypt"))
+		if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "decrypt"))
 		{
-		  LOGERR("Failed to load base packages.\n");
-		  goto error;
+			LOGERR("Failed to load base packages.\n");
+			goto error;
 		}
-	  else
-		check = 1;
+		else
+			check = 1;
 	}
-  if (check == 0
-	  && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main"))
-	{
-	  std::string theme_path;
 
-	  theme_path = DataManager::GetSettingsStoragePath ();
-	  if (!PartitionManager.Mount_Settings_Storage(false))
+	if (check == 0 && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main"))
+	{
+		std::string theme_path;
+
+		theme_path = DataManager::GetSettingsStoragePath();
+		if (!PartitionManager.Mount_Settings_Storage(false))
 		{
-		  int retry_count = 5;
-		  while (retry_count > 0
-				 && !PartitionManager.Mount_Settings_Storage(false))
+			int retry_count = 5;
+			while (retry_count > 0 && !PartitionManager.Mount_Settings_Storage(false))
 			{
-			  usleep (500000);
-			  retry_count--;
+				usleep(500000);
+				retry_count--;
 			}
-		  if (!PartitionManager.Mount_Settings_Storage(false))
+
+			if (!PartitionManager.Mount_Settings_Storage(false))
 			{
-			  LOGERR("Unable to mount %s during GUI startup.\n",
-					theme_path.c_str ());
-			  check = 1;
+				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"))
+		theme_path += "/TWRP/theme/ui.zip";
+		if (check || PageManager::LoadPackage("TWRP", theme_path, "main"))
 		{
-		  if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
+			if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "main"))
 			{
-			  LOGERR("Failed to load base packages.\n");
-			  goto error;
+				LOGERR("Failed to load base packages.\n");
+				goto error;
 			}
 		}
 	}
 
-  // Set the default package
-  PageManager::SelectPackage ("TWRP");
+	// Set the default package
+	PageManager::SelectPackage("TWRP");
 
-  gGuiInitialized = 1;
-  return 0;
+	gGuiInitialized = 1;
+	return 0;
 
 error:
-  LOGERR("An internal error has occurred.\n");
-  gGuiInitialized = 0;
-  return -1;
+	LOGERR("An internal error has occurred.\n");
+	gGuiInitialized = 0;
+	return -1;
 }
 
-extern "C" int
-gui_start ()
+extern "C" int gui_start(void)
 {
-  if (!gGuiInitialized)
-	return -1;
+	if (!gGuiInitialized)
+		return -1;
 
-  gGuiConsoleTerminate = 1;
-  while (gGuiConsoleRunning)
-	loopTimer ();
+	gGuiConsoleTerminate = 1;
 
-  // Set the default package
-  PageManager::SelectPackage ("TWRP");
+	while (gGuiConsoleRunning)
+		loopTimer();
 
-  if (!gGuiInputRunning)
+	// Set the default package
+	PageManager::SelectPackage("TWRP");
+
+	if (!gGuiInputRunning)
 	{
-	  // Start by spinning off an input handler.
-	  pthread_t t;
-	  pthread_create (&t, NULL, input_thread, NULL);
-	  gGuiInputRunning = 1;
+		// Start by spinning off an input handler.
+		pthread_t t;
+		pthread_create(&t, NULL, input_thread, NULL);
+		gGuiInputRunning = 1;
 	}
 
-  return runPages ();
+	return runPages();
 }
 
-extern "C" int
-gui_startPage (const char *page_name)
+extern "C" int gui_startPage(const char *page_name)
 {
-  if (!gGuiInitialized)
-	return -1;
+	if (!gGuiInitialized)
+		return -1;
 
-  gGuiConsoleTerminate = 1;
-  while (gGuiConsoleRunning)
-	loopTimer ();
+	gGuiConsoleTerminate = 1;
 
-  // Set the default package
-  PageManager::SelectPackage("TWRP");
+	while (gGuiConsoleRunning)
+		loopTimer();
 
-  if (!gGuiInputRunning)
+	// Set the default package
+	PageManager::SelectPackage("TWRP");
+
+	if (!gGuiInputRunning)
 	{
-	  // Start by spinning off an input handler.
-	  pthread_t t;
-	  pthread_create (&t, NULL, input_thread, NULL);
-	  gGuiInputRunning = 1;
+		// Start by spinning off an input handler.
+		pthread_t t;
+		pthread_create(&t, NULL, input_thread, NULL);
+		gGuiInputRunning = 1;
 	}
 
-  DataManager::SetValue("tw_page_done", 0);
-  return runPage (page_name);
+	DataManager::SetValue("tw_page_done", 0);
+	return runPage(page_name);
 }
 
-static void *
-console_thread (void *cookie)
+static void * console_thread(void *cookie)
 {
-  PageManager::SwitchToConsole ();
+	PageManager::SwitchToConsole();
 
-  while (!gGuiConsoleTerminate)
+	while (!gGuiConsoleTerminate)
 	{
-	  loopTimer ();
+		loopTimer();
 
-	  if (!gForceRender)
+		if (!gForceRender)
 		{
-		  int ret;
+			int ret;
 
-		  ret = PageManager::Update ();
-		  if (ret > 1)
-			PageManager::Render ();
+			ret = PageManager::Update();
+			if (ret > 1)
+				PageManager::Render();
 
-		  if (ret > 0)
-			flip ();
+			if (ret > 0)
+				flip();
 
-		  if (ret < 0)
-			LOGERR("An update request has failed.\n");
+			if (ret < 0)
+				LOGERR("An update request has failed.\n");
 		}
-	  else
+		else
 		{
-		  pthread_mutex_lock(&gForceRendermutex);
-		  gForceRender = 0;
-		  pthread_mutex_unlock(&gForceRendermutex);
-		  PageManager::Render ();
-		  flip ();
+			pthread_mutex_lock(&gForceRendermutex);
+			gForceRender = 0;
+			pthread_mutex_unlock(&gForceRendermutex);
+			PageManager::Render();
+			flip();
 		}
 	}
-  gGuiConsoleRunning = 0;
-  return NULL;
+	gGuiConsoleRunning = 0;
+	return NULL;
 }
 
-extern "C" int
-gui_console_only ()
+extern "C" int gui_console_only(void)
 {
-  if (!gGuiInitialized)
-	return -1;
+	if (!gGuiInitialized)
+		return -1;
 
-  gGuiConsoleTerminate = 0;
-  gGuiConsoleRunning = 1;
+	gGuiConsoleTerminate = 0;
+	gGuiConsoleRunning = 1;
 
-  // Start by spinning off an input handler.
-  pthread_t t;
-  pthread_create (&t, NULL, console_thread, NULL);
+	// Start by spinning off an input handler.
+	pthread_t t;
+	pthread_create(&t, NULL, console_thread, NULL);
 
-  return 0;
+	return 0;
 }
diff --git a/gui/hardwarekeyboard.cpp b/gui/hardwarekeyboard.cpp
index 96958d5..a5a9987 100644
--- a/gui/hardwarekeyboard.cpp
+++ b/gui/hardwarekeyboard.cpp
@@ -26,15 +26,18 @@
 #include "rapidxml.hpp"
 #include "objects.hpp"
 
-HardwareKeyboard::HardwareKeyboard(void) {
-	// Do Nothing
+HardwareKeyboard::HardwareKeyboard(void)
+{
+
 }
 
-HardwareKeyboard::~HardwareKeyboard() {
-	// Do Nothing
+HardwareKeyboard::~HardwareKeyboard()
+{
+	
 }
 
-int HardwareKeyboard::KeyDown(int key_code) {
+int HardwareKeyboard::KeyDown(int key_code)
+{
 #ifdef _EVENT_LOGGING
 	LOGERR("HardwareKeyboard::KeyDown %i\n", key_code);
 #endif
@@ -42,14 +45,16 @@
 	return 0; // 0 = no key repeat anything else turns on key repeat
 }
 
-int HardwareKeyboard::KeyUp(int key_code) {
+int HardwareKeyboard::KeyUp(int key_code)
+{
 #ifdef _EVENT_LOGGING
 	LOGERR("HardwareKeyboard::KeyUp %i\n", key_code);
 #endif
 	return 0;
 }
 
-int HardwareKeyboard::KeyRepeat(void) {
+int HardwareKeyboard::KeyRepeat(void)
+{
 #ifdef _EVENT_LOGGING
 	LOGERR("HardwareKeyboard::KeyRepeat\n");
 #endif
diff --git a/gui/image.cpp b/gui/image.cpp
index c684d1b..45d8636 100644
--- a/gui/image.cpp
+++ b/gui/image.cpp
@@ -27,71 +27,76 @@
 
 GUIImage::GUIImage(xml_node<>* node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mImage = NULL;
+	mImage = NULL;
 	mHighlightImage = NULL;
 	isHighlighted = false;
 
-    if (!node)
-        return;
+	if (!node)
+		return;
 
-    child = node->first_node("image");
-    if (child)
-    {
-        attr = child->first_attribute("resource");
-        if (attr)
-            mImage = PageManager::FindResource(attr->value());
+	child = node->first_node("image");
+	if (child)
+	{
+		attr = child->first_attribute("resource");
+		if (attr)
+			mImage = PageManager::FindResource(attr->value());
 		attr = child->first_attribute("highlightresource");
-        if (attr)
-            mHighlightImage = PageManager::FindResource(attr->value());
-    }
+		if (attr)
+			mHighlightImage = PageManager::FindResource(attr->value());
+	}
 
-    // Load the placement
-    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement);
+	// Load the placement
+	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, NULL, NULL, &mPlacement);
 
-    if (mImage && mImage->GetResource())
-    {
-        mRenderW = gr_get_width(mImage->GetResource());
-        mRenderH = gr_get_height(mImage->GetResource());
+	if (mImage && mImage->GetResource())
+	{
+		mRenderW = gr_get_width(mImage->GetResource());
+		mRenderH = gr_get_height(mImage->GetResource());
 
-        // Adjust for placement
-        if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
-        {
-            if (mPlacement == CENTER)
-                mRenderX -= (mRenderW / 2);
-            else
-                mRenderX -= mRenderW;
-        }
-        if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
-        {
-            if (mPlacement == CENTER)
-                mRenderY -= (mRenderH / 2);
-            else
-                mRenderY -= mRenderH;
-        }
-        SetPlacement(TOP_LEFT);
-    }
+		// Adjust for placement
+		if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
+		{
+			if (mPlacement == CENTER)
+				mRenderX -= (mRenderW / 2);
+			else
+				mRenderX -= mRenderW;
+		}
+		if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
+		{
+			if (mPlacement == CENTER)
+				mRenderY -= (mRenderH / 2);
+			else
+				mRenderY -= mRenderH;
+		}
+		SetPlacement(TOP_LEFT);
+	}
 
-    return;
+	return;
 }
 
 int GUIImage::Render(void)
 {
-    if (isHighlighted && mHighlightImage && mHighlightImage->GetResource()) {
+	if (isHighlighted && mHighlightImage && mHighlightImage->GetResource()) {
 		gr_blit(mHighlightImage->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
 		return 0;
-	} else if (!mImage || !mImage->GetResource())      return -1;
-    gr_blit(mImage->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
-    return 0;
+	}
+	else if (!mImage || !mImage->GetResource())
+		return -1;
+
+	gr_blit(mImage->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
+	return 0;
 }
 
 int GUIImage::SetRenderPos(int x, int y, int w, int h)
 {
-    if (w || h)     return -1;
-    mRenderX = x;
-    mRenderY = y;
-    return 0;
+	if (w || h)
+		return -1;
+
+	mRenderX = x;
+	mRenderY = y;
+	return 0;
 }
 
diff --git a/gui/input.cpp b/gui/input.cpp
index e016724..19e4e6a 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -29,17 +29,17 @@
 #include "../data.hpp"
 
 GUIInput::GUIInput(xml_node<>* node)
-    : Conditional(node)
+	: Conditional(node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mInputText = NULL;
+	mInputText = NULL;
 	mAction = NULL;
 	mBackground = NULL;
 	mCursor = NULL;
 	mFont = NULL;
-    mRendered = false;
+	mRendered = false;
 	HasMask = false;
 	DrawCursor = false;
 	isLocalChange = true;
@@ -52,18 +52,19 @@
 	ConvertStrToColor("black", &mBackgroundColor);
 	ConvertStrToColor("white", &mCursorColor);
 
-    if (!node)  return;
+	if (!node)
+		return;
 
-    // Load text directly from the node
-    mInputText = new GUIText(node);
+	// Load text directly from the node
+	mInputText = new GUIText(node);
 	// Load action directly from the node
 	mAction = new GUIAction(node);
 
 	if (mInputText->Render() < 0)
-    {
-        delete mInputText;
-        mInputText = NULL;
-    }
+	{
+		delete mInputText;
+		mInputText = NULL;
+	}
 
 	// Load the background
 	child = node->first_node("background");
@@ -114,18 +115,18 @@
 	DrawCursor = HasInputFocus;
 
 	// Load the font, and possibly override the color
-    child = node->first_node("font");
-    if (child)
-    {
-        attr = child->first_attribute("resource");
-        if (attr) {
-            mFont = PageManager::FindResource(attr->value());
+	child = node->first_node("font");
+	if (child)
+	{
+		attr = child->first_attribute("resource");
+		if (attr) {
+			mFont = PageManager::FindResource(attr->value());
 			gr_getFontDetails(mFont ? mFont->GetResource() : NULL, &mFontHeight, NULL);
 		}
-    }
+	}
 
 	child = node->first_node("text");
-    if (child)  mText = child->value();
+	if (child)  mText = child->value();
 	mLastValue = gui_parse_text(mText);
 
 	child = node->first_node("data");
@@ -175,7 +176,7 @@
 		}
 	}
 
-    // Load the placement
+	// Load the placement
 	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH);
 	SetActionPos(mRenderX, mRenderY, mRenderW, mRenderH);
 
@@ -190,17 +191,15 @@
 
 	isLocalChange = false;
 	HandleTextLocation(-3);
-
-    return;
 }
 
 GUIInput::~GUIInput()
 {
-    if (mInputText)     delete mInputText;
-	if (mBackground)    delete mBackground;
-	if (mCursor)        delete mCursor;
-	if (mFont)          delete mFont;
-	if (mAction)        delete mAction;
+	if (mInputText)	 	delete mInputText;
+	if (mBackground)	delete mBackground;
+	if (mCursor)		delete mCursor;
+	if (mFont)			delete mFont;
+	if (mAction)		delete mAction;
 }
 
 int GUIInput::HandleTextLocation(int x)
@@ -209,7 +208,8 @@
 	string displayValue, originalValue, insertChar;
 	void* fontResource = NULL;
 
-	if (mFont)  fontResource = mFont->GetResource();
+	if (mFont)
+		fontResource = mFont->GetResource();
 
 	DataManager::GetValue(mVariable, originalValue);
 	displayValue = originalValue;
@@ -229,9 +229,10 @@
 		mRendered = false;
 		return 0;
 	}
-	if (skipChars && skipChars < displayValue.size()) {
+
+	if (skipChars && skipChars < displayValue.size())
 		displayValue.erase(0, skipChars);
-	}
+
 	textWidth = gr_measureEx(displayValue.c_str(), fontResource);
 	mRendered = false;
 
@@ -239,9 +240,9 @@
 
 	if (x < -1000) {
 		// No change in scrolling
-		if (x == -1003) {
+		if (x == -1003)
 			mCursorLocation = -1;
-		}
+
 		if (mCursorLocation == -1) {
 			displayValue = originalValue;
 			skipChars = 0;
@@ -372,15 +373,15 @@
 int GUIInput::Render(void)
 {
 	if (!isConditionTrue())
-    {
-        mRendered = false;
-        return 0;
-    }
+	{
+		mRendered = false;
+		return 0;
+	}
 
 	void* fontResource = NULL;
 	if (mFont)  fontResource = mFont->GetResource();
 
-    // First step, fill background
+	// First step, fill background
 	gr_color(mBackgroundColor.red, mBackgroundColor.green, mBackgroundColor.blue, 255);
 	gr_fill(mRenderX, mRenderY, mRenderW, mRenderH);
 
@@ -394,11 +395,11 @@
 
 	int ret = 0;
 
-    // Render the text
+	// Render the text
 	mInputText->SetRenderPos(mRenderX + scrollingX, mFontY);
 	mInputText->SetMaxWidth(mRenderW - scrollingX);
-	if (mInputText)     ret = mInputText->Render();
-    if (ret < 0)        return ret;
+	if (mInputText)	 ret = mInputText->Render();
+	if (ret < 0)		return ret;
 
 	if (HasInputFocus && DrawCursor) {
 		// Render the cursor
@@ -451,21 +452,21 @@
 		gr_fill(cursorX, mFontY, CursorWidth, mFontHeight);
 	}
 
-    mRendered = true;
-    return ret;
+	mRendered = true;
+	return ret;
 }
 
 int GUIInput::Update(void)
 {
-    if (!isConditionTrue())     return (mRendered ? 2 : 0);
-    if (!mRendered)             return 2;
+	if (!isConditionTrue())	 return (mRendered ? 2 : 0);
+	if (!mRendered)			 return 2;
 
-    int ret = 0;
+	int ret = 0;
 
-    if (mInputText)         ret = mInputText->Update();
-    if (ret < 0)            return ret;
+	if (mInputText)		 ret = mInputText->Update();
+	if (ret < 0)			return ret;
 
-    return ret;
+	return ret;
 }
 
 int GUIInput::GetSelection(int x, int y)
@@ -476,14 +477,15 @@
 
 int GUIInput::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    static int startSelection = -1;
+	static int startSelection = -1;
 	int textWidth;
 	string displayValue, originalValue;
 	void* fontResource = NULL;
 
 	if (mFont)  fontResource = mFont->GetResource();
 
-	if (!isConditionTrue())     return -1;
+	if (!isConditionTrue())
+		return -1;
 
 	if (!HasInputFocus) {
 		if (state != TOUCH_RELEASE)
@@ -569,7 +571,7 @@
 			break;
 		}
 	}
-    return 0;
+	return 0;
 }
 
 int GUIInput::NotifyVarChange(std::string varName, std::string value)
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index 3af40ed..a4976f4 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -191,12 +191,12 @@
 
 		attr = child->first_attribute("highlightcolor");
 		memset(&mFontHighlightColor, 0, sizeof(COLOR));
-        if (attr)
-        {
-            std::string color = attr->value();
+		if (attr)
+		{
+			std::string color = attr->value();
 			ConvertStrToColor(color, &mFontHighlightColor);
 			hasFontHighlightColor = true;
-        }
+		}
 	}
 
 	// Load the separator if it exists
@@ -323,15 +323,15 @@
 
 	// Get the data for the list
 	child = node->first_node("listitem");
-    if (!child) return;
+	if (!child) return;
 	
 	while (child)
-    {
-        ListData data;
+	{
+		ListData data;
 
 		attr = child->first_attribute("name");
-        if (!attr) return;
-        data.displayName = attr->value();
+		if (!attr) return;
+		data.displayName = attr->value();
 
 		data.variableValue = child->value();
 		if (child->value() == currentValue) {
@@ -340,10 +340,10 @@
 			data.selected = 0;
 		}
 
-        mList.push_back(data);
+		mList.push_back(data);
 
-        child = child->next_sibling("listitem");
-    }
+		child = child->next_sibling("listitem");
+	}
 }
 
 GUIListBox::~GUIListBox()
@@ -430,21 +430,21 @@
 		}
 
 		if (mList.at(line + mStart).selected != 0)
-        {
-            icon = mIconSelected;
+		{
+			icon = mIconSelected;
 			currentIconHeight = mSelectedIconHeight;
 			currentIconWidth = mSelectedIconWidth;
 			currentIconOffsetY = SelectedIconOffsetY;
 			currentIconOffsetX = SelectedIconOffsetX;
-        }
-        else
-        {
-            icon = mIconUnselected;
+		}
+		else
+		{
+			icon = mIconUnselected;
 			currentIconHeight = mSelectedIconHeight;
 			currentIconWidth = mSelectedIconWidth;
 			currentIconOffsetY = SelectedIconOffsetY;
 			currentIconOffsetX = SelectedIconOffsetX;
-        }
+		}
 
 		if (icon && icon->GetResource())
 		{
@@ -758,8 +758,8 @@
 		}
 	}
 	if (varName == mVariable)
-    {
-        int i, listSize = mList.size(), selected_index = 0;
+	{
+		int i, listSize = mList.size(), selected_index = 0;
 
 		currentValue = value;
 
@@ -783,8 +783,8 @@
 		}
 
 		mUpdate = 1;
-        return 0;
-    }
+		return 0;
+	}
 	return 0;
 }
 
diff --git a/gui/objects.hpp b/gui/objects.hpp
index ff5429a..8f6f9bb 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -39,124 +39,123 @@
 class RenderObject
 {
 public:
-    enum Placement {
-        TOP_LEFT = 0,
-        TOP_RIGHT = 1,
-        BOTTOM_LEFT = 2,
-        BOTTOM_RIGHT = 3,
-        CENTER = 4,
+	enum Placement {
+		TOP_LEFT = 0,
+		TOP_RIGHT = 1,
+		BOTTOM_LEFT = 2,
+		BOTTOM_RIGHT = 3,
+		CENTER = 4,
 		CENTER_X_ONLY = 5,
-    };
+	};
 
 public:
-    RenderObject()              { mRenderX = 0; mRenderY = 0; mRenderW = 0; mRenderH = 0; mPlacement = TOP_LEFT; }
-    virtual ~RenderObject()     {}
+	RenderObject() { mRenderX = 0; mRenderY = 0; mRenderW = 0; mRenderH = 0; mPlacement = TOP_LEFT; }
+	virtual ~RenderObject() {}
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void) = 0;
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void) = 0;
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void)        { return 0; }
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void) { return 0; }
 
-    // GetRenderPos - Returns the current position of the object
-    virtual int GetRenderPos(int& x, int& y, int& w, int& h)        { x = mRenderX; y = mRenderY; w = mRenderW; h = mRenderH; return 0; }
+	// GetRenderPos - Returns the current position of the object
+	virtual int GetRenderPos(int& x, int& y, int& w, int& h) { x = mRenderX; y = mRenderY; w = mRenderW; h = mRenderH; return 0; }
 
-    // SetRenderPos - Update the position of the object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0)    { mRenderX = x; mRenderY = y; if (w || h) { mRenderW = w; mRenderH = h; } return 0; }
+	// SetRenderPos - Update the position of the object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0) { mRenderX = x; mRenderY = y; if (w || h) { mRenderW = w; mRenderH = h; } return 0; }
 
-    // GetPlacement - Returns the current placement
-    virtual int GetPlacement(Placement& placement)                  { placement = mPlacement; return 0; }
+	// GetPlacement - Returns the current placement
+	virtual int GetPlacement(Placement& placement) { placement = mPlacement; return 0; }
 
-    // SetPlacement - Update the current placement
-    virtual int SetPlacement(Placement placement)                   { mPlacement = placement; return 0; }
+	// SetPlacement - Update the current placement
+	virtual int SetPlacement(Placement placement) { mPlacement = placement; return 0; }
 
-    // SetPageFocus - Notify when a page gains or loses focus
-    virtual void SetPageFocus(int inFocus)                          { return; }
+	// SetPageFocus - Notify when a page gains or loses focus
+	virtual void SetPageFocus(int inFocus) { return; }
 
 protected:
-    int mRenderX, mRenderY, mRenderW, mRenderH;
-    Placement mPlacement;
+	int mRenderX, mRenderY, mRenderW, mRenderH;
+	Placement mPlacement;
 };
 
 class ActionObject
 {
 public:
-    ActionObject()              { mActionX = 0; mActionY = 0; mActionW = 0; mActionH = 0; }
-    virtual ~ActionObject()     {}
+	ActionObject() { mActionX = 0; mActionY = 0; mActionW = 0; mActionH = 0; }
+	virtual ~ActionObject() {}
 
 public:
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y)        { return 0; }
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y) { return 0; }
 
-    // NotifyKey - Notify of a key press
-    //  Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error
-    virtual int NotifyKey(int key)                                  { return 1; }
+	// NotifyKey - Notify of a key press
+	//  Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error
+	virtual int NotifyKey(int key) { return 1; }
 
-    // GetRenderPos - Returns the current position of the object
-    virtual int GetActionPos(int& x, int& y, int& w, int& h)        { x = mActionX; y = mActionY; w = mActionW; h = mActionH; return 0; }
+	// GetRenderPos - Returns the current position of the object
+	virtual int GetActionPos(int& x, int& y, int& w, int& h) { x = mActionX; y = mActionY; w = mActionW; h = mActionH; return 0; }
 
-    // SetRenderPos - Update the position of the object
-    //  Return 0 on success, <0 on error
-    virtual int SetActionPos(int x, int y, int w = 0, int h = 0);
+	// SetRenderPos - Update the position of the object
+	//  Return 0 on success, <0 on error
+	virtual int SetActionPos(int x, int y, int w = 0, int h = 0);
 
-    // IsInRegion - Checks if the request is handled by this object
-    //  Return 0 if this object handles the request, 1 if not
-    virtual int IsInRegion(int x, int y)                            { return ((x < mActionX || x > mActionX + mActionW || y < mActionY || y > mActionY + mActionH) ? 0 : 1); }
+	// IsInRegion - Checks if the request is handled by this object
+	//  Return 0 if this object handles the request, 1 if not
+	virtual int IsInRegion(int x, int y) { return ((x < mActionX || x > mActionX + mActionW || y < mActionY || y > mActionY + mActionH) ? 0 : 1); }
 
-    // NotifyVarChange - Notify of a variable change
-    //  Returns 0 on success, <0 on error
-    virtual int NotifyVarChange(std::string varName, std::string value)     { return 0; }
+	// NotifyVarChange - Notify of a variable change
+	//  Returns 0 on success, <0 on error
+	virtual int NotifyVarChange(std::string varName, std::string value) { return 0; }
 
 protected:
-    int mActionX, mActionY, mActionW, mActionH;
+	int mActionX, mActionY, mActionW, mActionH;
 };
 
 class Conditional
 {
 public:
-    Conditional(xml_node<>* node);
+	Conditional(xml_node<>* node);
 
 public:
-    bool IsConditionVariable(std::string var);
-    bool isConditionTrue();
-    bool isConditionValid();
-    void NotifyPageSet();
+	bool IsConditionVariable(std::string var);
+	bool isConditionTrue();
+	bool isConditionValid();
+	void NotifyPageSet();
 
 protected:
-    class Condition
-    {
-    public:
-        std::string mVar1;
-        std::string mVar2;
-        std::string mCompareOp;
-        std::string mLastVal;
-    };
+	class Condition
+	{
+	public:
+		std::string mVar1;
+		std::string mVar2;
+		std::string mCompareOp;
+		std::string mLastVal;
+	};
 
-    std::vector<Condition> mConditions;
+	std::vector<Condition> mConditions;
 
 protected:
-    bool isMounted(std::string vol);
-    bool isConditionTrue(Condition* condition);
-
+	bool isMounted(std::string vol);
+	bool isConditionTrue(Condition* condition);
 };
 
 class InputObject
 {
 public:
-    InputObject()              { HasInputFocus = 0; }
-    virtual ~InputObject()     {}
+	InputObject() { HasInputFocus = 0; }
+	virtual ~InputObject() {}
 
 public:
-    // NotifyKeyboard - Notify of keyboard input
-    //  Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error
-    virtual int NotifyKeyboard(int key)                                  { return 1; }
+	// NotifyKeyboard - Notify of keyboard input
+	//  Return 0 on success (and consume key), >0 to pass key to next handler, and <0 on error
+	virtual int NotifyKeyboard(int key) { return 1; }
 
-	virtual int SetInputFocus(int focus)    { HasInputFocus = focus; return 1; }
+	virtual int SetInputFocus(int focus) { HasInputFocus = focus; return 1; }
 
 protected:
 	int HasInputFocus;
@@ -165,26 +164,25 @@
 // Derived Objects
 // GUIText - Used for static text
 class GUIText : public RenderObject, public ActionObject, public Conditional
-
 {
 public:
-    // w and h may be ignored, in which case, no bounding box is applied
-    GUIText(xml_node<>* node);
+	// w and h may be ignored, in which case, no bounding box is applied
+	GUIText(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // Retrieve the size of the current string (dynamic strings may change per call)
-    virtual int GetCurrentBounds(int& w, int& h);
+	// Retrieve the size of the current string (dynamic strings may change per call)
+	virtual int GetCurrentBounds(int& w, int& h);
 
-    // Notify of a variable change
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// Notify of a variable change
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
 	// Set maximum width in pixels
 	virtual int SetMaxWidth(unsigned width);
@@ -196,42 +194,42 @@
 	bool isHighlighted;
 
 protected:
-    std::string mText;
-    std::string mLastValue;
-    COLOR mColor;
+	std::string mText;
+	std::string mLastValue;
+	COLOR mColor;
 	COLOR mHighlightColor;
-    Resource* mFont;
-    int mIsStatic;
-    int mVarChanged;
-    int mFontHeight;
+	Resource* mFont;
+	int mIsStatic;
+	int mVarChanged;
+	int mFontHeight;
 	unsigned maxWidth;
 	unsigned charSkip;
 	bool hasHighlightColor;
 
 protected:
-    std::string parseText(void);
+	std::string parseText(void);
 };
 
 // GUIImage - Used for static image
 class GUIImage : public RenderObject
 {
 public:
-    GUIImage(xml_node<>* node);
+	GUIImage(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // SetRenderPos - Update the position of the object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetRenderPos - Update the position of the object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
 public:
 	bool isHighlighted;
 
 protected:
-    Resource* mImage;
+	Resource* mImage;
 	Resource* mHighlightImage;
 };
 
@@ -239,46 +237,46 @@
 class GUIFill : public RenderObject
 {
 public:
-    GUIFill(xml_node<>* node);
+	GUIFill(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
 protected:
-    COLOR mColor;
+	COLOR mColor;
 };
 
 // GUIAction - Used for standard actions
 class GUIAction : public ActionObject, public Conditional
 {
 public:
-    GUIAction(xml_node<>* node);
+	GUIAction(xml_node<>* node);
 
 public:
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
-    virtual int NotifyKey(int key);
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	virtual int NotifyKey(int key);
+	virtual int NotifyVarChange(std::string varName, std::string value);
 	virtual int doActions();
 
 protected:
-    class Action
-    {
-    public:
-        std::string mFunction;
-        std::string mArg;
-    };
+	class Action
+	{
+	public:
+		std::string mFunction;
+		std::string mArg;
+	};
 
-    std::vector<Action> mActions;
-    int mKey;
+	std::vector<Action> mActions;
+	int mKey;
 
 protected:
-    int getKeyByName(std::string key);
-    virtual int doAction(Action action, int isThreaded = 0);
-    static void* thread_start(void *cookie);
+	int getKeyByName(std::string key);
+	virtual int doAction(Action action, int isThreaded = 0);
+	static void* thread_start(void *cookie);
 	void simulate_progress_bar(void);
-    int flash_zip(std::string filename, std::string pageName, const int simulate, int* wipe_cache);
+	int flash_zip(std::string filename, std::string pageName, const int simulate, int* wipe_cache);
 	void operation_start(const string operation_name);
 	void operation_end(const int operation_status, const int simulate);
 	static void* command_thread(void *cookie);
@@ -287,92 +285,92 @@
 class GUIConsole : public RenderObject, public ActionObject
 {
 public:
-    GUIConsole(xml_node<>* node);
+	GUIConsole(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // SetRenderPos - Update the position of the object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetRenderPos - Update the position of the object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // IsInRegion - Checks if the request is handled by this object
-    //  Return 0 if this object handles the request, 1 if not
-    virtual int IsInRegion(int x, int y);
+	// IsInRegion - Checks if the request is handled by this object
+	//  Return 0 if this object handles the request, 1 if not
+	virtual int IsInRegion(int x, int y);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers)
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error (Return error to allow other handlers)
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
 protected:
-    enum SlideoutState
-    {
-        hidden = 0,
-        visible,
-        request_hide,
-        request_show
-    };
-    Resource* mFont;
-    Resource* mSlideoutImage;
-    COLOR mForegroundColor;
-    COLOR mBackgroundColor;
-    COLOR mScrollColor;
-    unsigned int mFontHeight;
-    int mCurrentLine;
-    unsigned int mLastCount;
-    unsigned int mMaxRows;
-    int mStartY;
-    int mSlideoutX, mSlideoutY, mSlideoutW, mSlideoutH;
-    int mSlideinX, mSlideinY, mSlideinW, mSlideinH;
-    int mConsoleX, mConsoleY, mConsoleW, mConsoleH;
-    int mLastTouchX, mLastTouchY;
-    int mSlideMultiplier;
-    int mSlideout;
-    SlideoutState mSlideoutState;
+	enum SlideoutState
+	{
+		hidden = 0,
+		visible,
+		request_hide,
+		request_show
+	};
+
+	Resource* mFont;
+	Resource* mSlideoutImage;
+	COLOR mForegroundColor;
+	COLOR mBackgroundColor;
+	COLOR mScrollColor;
+	unsigned int mFontHeight;
+	int mCurrentLine;
+	unsigned int mLastCount;
+	unsigned int mMaxRows;
+	int mStartY;
+	int mSlideoutX, mSlideoutY, mSlideoutW, mSlideoutH;
+	int mSlideinX, mSlideinY, mSlideinW, mSlideinH;
+	int mConsoleX, mConsoleY, mConsoleW, mConsoleH;
+	int mLastTouchX, mLastTouchY;
+	int mSlideMultiplier;
+	int mSlideout;
+	SlideoutState mSlideoutState;
 
 protected:
-    virtual int RenderSlideout(void);
-    virtual int RenderConsole(void);
-
+	virtual int RenderSlideout(void);
+	virtual int RenderConsole(void);
 };
 
 class GUIButton : public RenderObject, public ActionObject, public Conditional
 {
 public:
-    GUIButton(xml_node<>* node);
-    virtual ~GUIButton();
+	GUIButton(xml_node<>* node);
+	virtual ~GUIButton();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // SetPos - Update the position of the render object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetPos - Update the position of the render object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
 protected:
-    GUIImage* mButtonImg;
-    Resource* mButtonIcon;
-    GUIText* mButtonLabel;
-    GUIAction* mAction;
-    int mTextX, mTextY, mTextW, mTextH;
-    int mIconX, mIconY, mIconW, mIconH;
-    bool mRendered;
+	GUIImage* mButtonImg;
+	Resource* mButtonIcon;
+	GUIText* mButtonLabel;
+	GUIAction* mAction;
+	int mTextX, mTextY, mTextW, mTextH;
+	int mIconX, mIconY, mIconW, mIconH;
+	bool mRendered;
 	bool hasHighlightColor;
 	bool renderHighlight;
 	bool hasFill;
@@ -383,103 +381,103 @@
 class GUICheckbox: public RenderObject, public ActionObject, public Conditional
 {
 public:
-    GUICheckbox(xml_node<>* node);
-    virtual ~GUICheckbox();
+	GUICheckbox(xml_node<>* node);
+	virtual ~GUICheckbox();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // SetPos - Update the position of the render object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetPos - Update the position of the render object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
 protected:
-    Resource* mChecked;
-    Resource* mUnchecked;
-    GUIText* mLabel;
-    int mTextX, mTextY;
-    int mCheckX, mCheckY, mCheckW, mCheckH;
-    int mLastState;
-    bool mRendered;
-    std::string mVarName;
+	Resource* mChecked;
+	Resource* mUnchecked;
+	GUIText* mLabel;
+	int mTextX, mTextY;
+	int mCheckX, mCheckY, mCheckW, mCheckH;
+	int mLastState;
+	bool mRendered;
+	std::string mVarName;
 };
 
 class GUIFileSelector : public RenderObject, public ActionObject
 {
 public:
-    GUIFileSelector(xml_node<>* node);
-    virtual ~GUIFileSelector();
+	GUIFileSelector(xml_node<>* node);
+	virtual ~GUIFileSelector();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
-    // NotifyVarChange - Notify of a variable change
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// NotifyVarChange - Notify of a variable change
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
-    // SetPos - Update the position of the render object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetPos - Update the position of the render object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // SetPageFocus - Notify when a page gains or loses focus
-    virtual void SetPageFocus(int inFocus);
+	// SetPageFocus - Notify when a page gains or loses focus
+	virtual void SetPageFocus(int inFocus);
 
 protected:
-    struct FileData {
-        std::string fileName;
-        unsigned char fileType;     // Uses d_type format from struct dirent
-        mode_t protection;          // Uses mode_t format from stat
-        uid_t userId;
-        gid_t groupId;
-        off_t fileSize;
-        time_t lastAccess;          // Uses time_t format from stat
-        time_t lastModified;        // Uses time_t format from stat
-        time_t lastStatChange;      // Uses time_t format from stat
-    };
+	struct FileData {
+		std::string fileName;
+		unsigned char fileType;	 // Uses d_type format from struct dirent
+		mode_t protection;		  // Uses mode_t format from stat
+		uid_t userId;
+		gid_t groupId;
+		off_t fileSize;
+		time_t lastAccess;		  // Uses time_t format from stat
+		time_t lastModified;		// Uses time_t format from stat
+		time_t lastStatChange;	  // Uses time_t format from stat
+	};
 
 protected:
-    virtual int GetSelection(int x, int y);
+	virtual int GetSelection(int x, int y);
 
-    virtual int GetFileList(const std::string folder);
-    static bool fileSort(FileData d1, FileData d2);
+	virtual int GetFileList(const std::string folder);
+	static bool fileSort(FileData d1, FileData d2);
 
 protected:
-    std::vector<FileData> mFolderList;
-    std::vector<FileData> mFileList;
-    std::string mPathVar;
-    std::string mExtn;
-    std::string mVariable;
+	std::vector<FileData> mFolderList;
+	std::vector<FileData> mFileList;
+	std::string mPathVar;
+	std::string mExtn;
+	std::string mVariable;
 	std::string mSortVariable;
 	std::string mSelection;
 	std::string mHeaderText;
 	std::string mLastValue;
-    int actualLineHeight;
+	int actualLineHeight;
 	int mStart;
-    int mLineSpacing;
+	int mLineSpacing;
 	int mSeparatorH;
 	int mHeaderSeparatorH;
-    int mShowFolders, mShowFiles, mShowNavFolders;
-    int mUpdate;
-    int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH;
+	int mShowFolders, mShowFiles, mShowNavFolders;
+	int mUpdate;
+	int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH;
 	int mHeaderH;
 	int mFastScrollW;
 	int mFastScrollLineW;
@@ -493,16 +491,16 @@
 	int scrollingY;
 	int mHeaderIsStatic;
 	int touchDebounce;
-    unsigned mFontHeight;
-    unsigned mLineHeight;
-    int mIconWidth, mIconHeight, mFolderIconHeight, mFileIconHeight, mFolderIconWidth, mFileIconWidth, mHeaderIconHeight, mHeaderIconWidth;
-    Resource* mHeaderIcon;
+	unsigned mFontHeight;
+	unsigned mLineHeight;
+	int mIconWidth, mIconHeight, mFolderIconHeight, mFileIconHeight, mFolderIconWidth, mFileIconWidth, mHeaderIconHeight, mHeaderIconWidth;
+	Resource* mHeaderIcon;
 	Resource* mFolderIcon;
-    Resource* mFileIcon;
-    Resource* mBackground;
-    Resource* mFont;
-    COLOR mBackgroundColor;
-    COLOR mFontColor;
+	Resource* mFileIcon;
+	Resource* mBackground;
+	Resource* mFont;
+	COLOR mBackgroundColor;
+	COLOR mFontColor;
 	COLOR mHeaderBackgroundColor;
 	COLOR mHeaderFontColor;
 	COLOR mSeparatorColor;
@@ -521,56 +519,56 @@
 class GUIListBox : public RenderObject, public ActionObject
 {
 public:
-    GUIListBox(xml_node<>* node);
-    virtual ~GUIListBox();
+	GUIListBox(xml_node<>* node);
+	virtual ~GUIListBox();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
-    // NotifyVarChange - Notify of a variable change
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// NotifyVarChange - Notify of a variable change
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
-    // SetPos - Update the position of the render object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetPos - Update the position of the render object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // SetPageFocus - Notify when a page gains or loses focus
-    virtual void SetPageFocus(int inFocus);
+	// SetPageFocus - Notify when a page gains or loses focus
+	virtual void SetPageFocus(int inFocus);
 
 protected:
-    struct ListData {
-        std::string displayName;
+	struct ListData {
+		std::string displayName;
 		std::string variableValue;
 		unsigned int selected;
-    };
+	};
 
 protected:
-    virtual int GetSelection(int x, int y);
+	virtual int GetSelection(int x, int y);
 
 protected:
-    std::vector<ListData> mList;
-    std::string mVariable;
+	std::vector<ListData> mList;
+	std::string mVariable;
 	std::string mSelection;
 	std::string currentValue;
 	std::string mHeaderText;
 	std::string mLastValue;
 	int actualLineHeight;
-    int mStart;
+	int mStart;
 	int startY;
 	int mSeparatorH, mHeaderSeparatorH;
-    int mLineSpacing;
-    int mUpdate;
-    int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH;
+	int mLineSpacing;
+	int mUpdate;
+	int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH;
 	int mFastScrollW;
 	int mFastScrollLineW;
 	int mFastScrollRectW;
@@ -581,15 +579,15 @@
 	int scrollingSpeed;
 	int scrollingY;
 	static int mSortOrder;
-    unsigned mFontHeight;
-    unsigned mLineHeight;
+	unsigned mFontHeight;
+	unsigned mLineHeight;
 	Resource* mHeaderIcon;
-    Resource* mIconSelected;
-    Resource* mIconUnselected;
-    Resource* mBackground;
-    Resource* mFont;
-    COLOR mBackgroundColor;
-    COLOR mFontColor;
+	Resource* mIconSelected;
+	Resource* mIconUnselected;
+	Resource* mBackground;
+	Resource* mFont;
+	COLOR mBackgroundColor;
+	COLOR mFontColor;
 	COLOR mHeaderBackgroundColor;
 	COLOR mHeaderFontColor;
 	COLOR mSeparatorColor;
@@ -609,53 +607,51 @@
 class GUIPartitionList : public RenderObject, public ActionObject
 {
 public:
-    GUIPartitionList(xml_node<>* node);
-    virtual ~GUIPartitionList();
+	GUIPartitionList(xml_node<>* node);
+	virtual ~GUIPartitionList();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
-    // NotifyVarChange - Notify of a variable change
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// NotifyVarChange - Notify of a variable change
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
-    // SetPos - Update the position of the render object
-    //  Return 0 on success, <0 on error
-    virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
+	// SetPos - Update the position of the render object
+	//  Return 0 on success, <0 on error
+	virtual int SetRenderPos(int x, int y, int w = 0, int h = 0);
 
-    // SetPageFocus - Notify when a page gains or loses focus
-    virtual void SetPageFocus(int inFocus);
+	// SetPageFocus - Notify when a page gains or loses focus
+	virtual void SetPageFocus(int inFocus);
 
 protected:
-
-protected:
-    virtual int GetSelection(int x, int y);
+	virtual int GetSelection(int x, int y);
 	virtual void MatchList(void);
 
 protected:
-    std::vector<PartitionList> mList;
+	std::vector<PartitionList> mList;
 	std::string ListType;
-    std::string mVariable;
+	std::string mVariable;
 	std::string selectedList;
 	std::string currentValue;
 	std::string mHeaderText;
 	std::string mLastValue;
 	int actualLineHeight;
-    int mStart;
+	int mStart;
 	int startY;
 	int mSeparatorH, mHeaderSeparatorH;
-    int mLineSpacing;
-    int mUpdate;
-    int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH;
+	int mLineSpacing;
+	int mUpdate;
+	int mBackgroundX, mBackgroundY, mBackgroundW, mBackgroundH, mHeaderH;
 	int mFastScrollW;
 	int mFastScrollLineW;
 	int mFastScrollRectW;
@@ -666,15 +662,15 @@
 	int scrollingSpeed;
 	int scrollingY;
 	static int mSortOrder;
-    unsigned mFontHeight;
-    unsigned mLineHeight;
+	unsigned mFontHeight;
+	unsigned mLineHeight;
 	Resource* mHeaderIcon;
-    Resource* mIconSelected;
-    Resource* mIconUnselected;
-    Resource* mBackground;
-    Resource* mFont;
-    COLOR mBackgroundColor;
-    COLOR mFontColor;
+	Resource* mIconSelected;
+	Resource* mIconUnselected;
+	Resource* mBackground;
+	Resource* mFont;
+	COLOR mBackgroundColor;
+	COLOR mFontColor;
 	COLOR mHeaderBackgroundColor;
 	COLOR mHeaderFontColor;
 	COLOR mSeparatorColor;
@@ -696,87 +692,86 @@
 class GUIAnimation : public RenderObject
 {
 public:
-    GUIAnimation(xml_node<>* node);
+	GUIAnimation(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
 protected:
-    AnimationResource* mAnimation;
-    int mFrame;
-    int mFPS;
-    int mLoop;
-    int mRender;
-    int mUpdateCount;
+	AnimationResource* mAnimation;
+	int mFrame;
+	int mFPS;
+	int mLoop;
+	int mRender;
+	int mUpdateCount;
 };
 
 class GUIProgressBar : public RenderObject, public ActionObject
 {
 public:
-    GUIProgressBar(xml_node<>* node);
+	GUIProgressBar(xml_node<>* node);
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // NotifyVarChange - Notify of a variable change
-    //  Returns 0 on success, <0 on error
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// NotifyVarChange - Notify of a variable change
+	//  Returns 0 on success, <0 on error
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
 protected:
-    Resource* mEmptyBar;
-    Resource* mFullBar;
-    std::string mMinValVar;
-    std::string mMaxValVar;
-    std::string mCurValVar;
-    float mSlide;
-    float mSlideInc;
-    int mSlideFrames;
-    int mLastPos;
+	Resource* mEmptyBar;
+	Resource* mFullBar;
+	std::string mMinValVar;
+	std::string mMaxValVar;
+	std::string mCurValVar;
+	float mSlide;
+	float mSlideInc;
+	int mSlideFrames;
+	int mLastPos;
 
 protected:
-    virtual int RenderInternal(void);       // Does the actual render
-
+	virtual int RenderInternal(void);	   // Does the actual render
 };
 
 class GUISlider : public RenderObject, public ActionObject
 {
 public:
-    GUISlider(xml_node<>* node);
-    virtual ~GUISlider();
+	GUISlider(xml_node<>* node);
+	virtual ~GUISlider();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	// NotifyTouch - Notify of a touch event
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
 protected:
-    GUIAction* sAction;
-    Resource* sSlider;
-    Resource* sSliderUsed;
-    Resource* sTouch;
-    int sTouchW, sTouchH;
-    int sCurTouchX;
-    int sUpdate;
+	GUIAction* sAction;
+	Resource* sSlider;
+	Resource* sSliderUsed;
+	Resource* sTouch;
+	int sTouchW, sTouchH;
+	int sCurTouchX;
+	int sUpdate;
 };
 
 #define MAX_KEYBOARD_LAYOUTS 5
@@ -799,7 +794,7 @@
 {
 public:
 	GUIKeyboard(xml_node<>* node);
-    virtual ~GUIKeyboard();
+	virtual ~GUIKeyboard();
 
 public:
 	virtual int Render(void);
@@ -812,12 +807,12 @@
 
 protected:
 	struct keyboard_key_class
-    {
-        unsigned char key;
+	{
+		unsigned char key;
 		unsigned char longpresskey;
-        unsigned int end_x;
+		unsigned int end_x;
 		unsigned int layout;
-    };
+	};
 
 	Resource* keyboardImg[MAX_KEYBOARD_LAYOUTS];
 	struct keyboard_key_class keyboard_keys[MAX_KEYBOARD_LAYOUTS][MAX_KEYBOARD_ROWS][MAX_KEYBOARD_KEYS];
@@ -836,25 +831,25 @@
 class GUIInput : public RenderObject, public ActionObject, public Conditional, public InputObject
 {
 public:
-    // w and h may be ignored, in which case, no bounding box is applied
-    GUIInput(xml_node<>* node);
+	// w and h may be ignored, in which case, no bounding box is applied
+	GUIInput(xml_node<>* node);
 	virtual ~GUIInput();
 
 public:
-    // Render - Render the full object to the GL surface
-    //  Return 0 on success, <0 on error
-    virtual int Render(void);
+	// Render - Render the full object to the GL surface
+	//  Return 0 on success, <0 on error
+	virtual int Render(void);
 
-    // Update - Update any UI component animations (called <= 30 FPS)
-    //  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
-    virtual int Update(void);
+	// Update - Update any UI component animations (called <= 30 FPS)
+	//  Return 0 if nothing to update, 1 on success and contiue, >1 if full render required, and <0 on error
+	virtual int Update(void);
 
-    // Notify of a variable change
-    virtual int NotifyVarChange(std::string varName, std::string value);
+	// Notify of a variable change
+	virtual int NotifyVarChange(std::string varName, std::string value);
 
 	// NotifyTouch - Notify of a touch event
-    //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	//  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
 
 	virtual int NotifyKeyboard(int key);
 
@@ -865,17 +860,17 @@
 	virtual int HandleTextLocation(int x);
 
 protected:
-    GUIText* mInputText;
+	GUIText* mInputText;
 	GUIAction* mAction;
 	Resource* mBackground;
 	Resource* mCursor;
 	Resource* mFont;
 	std::string mText;
-    std::string mLastValue;
+	std::string mLastValue;
 	std::string mVariable;
 	std::string mMask;
 	std::string mMaskVariable;
-    COLOR mBackgroundColor;
+	COLOR mBackgroundColor;
 	COLOR mCursorColor;
 	int scrollingX;
 	int lastX;
diff --git a/gui/pages.cpp b/gui/pages.cpp
index 86d4dff..9aea1b8 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -50,27 +50,28 @@
 PageSet* PageManager::mCurrentSet;
 PageSet* PageManager::mBaseSet = NULL;
 
-
 // Helper routine to convert a string to a color declaration
 int ConvertStrToColor(std::string str, COLOR* color)
 {
-    // Set the default, solid black
-    memset(color, 0, sizeof(COLOR));
-    color->alpha = 255;
+	// Set the default, solid black
+	memset(color, 0, sizeof(COLOR));
+	color->alpha = 255;
 
-    // Translate variables
-    DataManager::GetValue(str, str);
-    
-    // Look for some defaults
-    if (str == "black")         return 0;
-    else if (str == "white")    { color->red = color->green = color->blue = 255; return 0; }
-    else if (str == "red")      { color->red = 255; return 0; }
-    else if (str == "green")    { color->green = 255; return 0; }
-    else if (str == "blue")     { color->blue = 255; return 0; }
+	// Translate variables
+	DataManager::GetValue(str, str);
+	
+	// Look for some defaults
+	if (str == "black")			return 0;
+	else if (str == "white")	{ color->red = color->green = color->blue = 255; return 0; }
+	else if (str == "red")		{ color->red = 255; return 0; }
+	else if (str == "green")	{ color->green = 255; return 0; }
+	else if (str == "blue")		{ color->blue = 255; return 0; }
 
-    // At this point, we require an RGB(A) color
-    if (str[0] != '#')          return -1;
-    str.erase(0, 1);
+	// At this point, we require an RGB(A) color
+	if (str[0] != '#')
+		return -1;
+
+	str.erase(0, 1);
 
 	int result;
 	if (str.size() >= 8) {
@@ -95,186 +96,188 @@
 // Helper APIs
 bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w /* = NULL */, int* h /* = NULL */, RenderObject::Placement* placement /* = NULL */)
 {
-    if (!node)      return false;
+	if (!node)
+		return false;
 
-    std::string value;
-    if (node->first_attribute("x"))
-    {
-        value = node->first_attribute("x")->value();
-        DataManager::GetValue(value, value);
-        *x = atol(value.c_str());
-    }
+	std::string value;
+	if (node->first_attribute("x"))
+	{
+		value = node->first_attribute("x")->value();
+		DataManager::GetValue(value, value);
+		*x = atol(value.c_str());
+	}
 
-    if (node->first_attribute("y"))
-    {
-        value = node->first_attribute("y")->value();
-        DataManager::GetValue(value, value);
-        *y = atol(value.c_str());
-    }
+	if (node->first_attribute("y"))
+	{
+		value = node->first_attribute("y")->value();
+		DataManager::GetValue(value, value);
+		*y = atol(value.c_str());
+	}
 
-    if (w && node->first_attribute("w"))
-    {
-        value = node->first_attribute("w")->value();
-        DataManager::GetValue(value, value);
-        *w = atol(value.c_str());
-    }
+	if (w && node->first_attribute("w"))
+	{
+		value = node->first_attribute("w")->value();
+		DataManager::GetValue(value, value);
+		*w = atol(value.c_str());
+	}
 
-    if (h && node->first_attribute("h"))
-    {
-        value = node->first_attribute("h")->value();
-        DataManager::GetValue(value, value);
-        *h = atol(value.c_str());
-    }
+	if (h && node->first_attribute("h"))
+	{
+		value = node->first_attribute("h")->value();
+		DataManager::GetValue(value, value);
+		*h = atol(value.c_str());
+	}
 
-    if (placement && node->first_attribute("placement"))
-    {
-        value = node->first_attribute("placement")->value();
-        DataManager::GetValue(value, value);
-        *placement = (RenderObject::Placement) atol(value.c_str());
-    }
+	if (placement && node->first_attribute("placement"))
+	{
+		value = node->first_attribute("placement")->value();
+		DataManager::GetValue(value, value);
+		*placement = (RenderObject::Placement) atol(value.c_str());
+	}
 
-    return true;
+	return true;
 }
 
 int ActionObject::SetActionPos(int x, int y, int w, int h)
 {
-    if (x < 0 || y < 0)                                     return -1;
+	if (x < 0 || y < 0)
+		return -1;
 
-    mActionX = x; 
-    mActionY = y; 
-    if (w || h)
-    {
-        mActionW = w;
-        mActionH = h;
-    }
-    return 0;
+	mActionX = x; 
+	mActionY = y; 
+	if (w || h)
+	{
+		mActionW = w;
+		mActionH = h;
+	}
+	return 0;
 }
 
 Page::Page(xml_node<>* page, xml_node<>* templates /* = NULL */)
 {
-    mTouchStart = NULL;
+	mTouchStart = NULL;
 
-    // We can memset the whole structure, because the alpha channel is ignored
-    memset(&mBackground, 0, sizeof(COLOR));
+	// We can memset the whole structure, because the alpha channel is ignored
+	memset(&mBackground, 0, sizeof(COLOR));
 
-    // With NULL, we make a console-only display
-    if (!page)
-    {
-        mName = "console";
+	// With NULL, we make a console-only display
+	if (!page)
+	{
+		mName = "console";
 
-        GUIConsole* element = new GUIConsole(NULL);
-        mRenders.push_back(element);
-        mActions.push_back(element);
-        return;
-    }
+		GUIConsole* element = new GUIConsole(NULL);
+		mRenders.push_back(element);
+		mActions.push_back(element);
+		return;
+	}
 
-    if (page->first_attribute("name"))
-        mName = page->first_attribute("name")->value();
-    else
-    {
-        LOGERR("No page name attribute found!\n");
-        return;
-    }
+	if (page->first_attribute("name"))
+		mName = page->first_attribute("name")->value();
+	else
+	{
+		LOGERR("No page name attribute found!\n");
+		return;
+	}
 
-    LOGINFO("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);
+	// This is a recursive routine for template handling
+	ProcessNode(page, templates);
 
-    return;
+	return;
 }
 
 bool Page::ProcessNode(xml_node<>* page, xml_node<>* templates /* = NULL */, int depth /* = 0 */)
 {
-    if (depth == 10)
-    {
-        LOGERR("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
-        return false;
-    }
+	if (depth == 10)
+	{
+		LOGERR("Page processing depth has exceeded 10. Failing out. This is likely a recursive template.\n");
+		return false;
+	}
 
-    // Let's retrieve the background value, if any
-    xml_node<>* bg = page->first_node("background");
-    if (bg)
-    {
-        xml_attribute<>* attr = bg->first_attribute("color");
-        if (attr)
-        {
-            std::string color = attr->value();
-            ConvertStrToColor(color, &mBackground);
-        }
-    }
+	// Let's retrieve the background value, if any
+	xml_node<>* bg = page->first_node("background");
+	if (bg)
+	{
+		xml_attribute<>* attr = bg->first_attribute("color");
+		if (attr)
+		{
+			std::string color = attr->value();
+			ConvertStrToColor(color, &mBackground);
+		}
+	}
 
-    xml_node<>* child;
-    child = page->first_node("object");
-    while (child)
-    {
-        if (!child->first_attribute("type"))
-            break;
+	xml_node<>* child;
+	child = page->first_node("object");
+	while (child)
+	{
+		if (!child->first_attribute("type"))
+			break;
 
-        std::string type = child->first_attribute("type")->value();
+		std::string type = child->first_attribute("type")->value();
 
-        if (type == "text")
-        {
-            GUIText* element = new GUIText(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
-        else if (type == "image")
-        {
-            GUIImage* element = new GUIImage(child);
-            mRenders.push_back(element);
-        }
-        else if (type == "fill")
-        {
-            GUIFill* element = new GUIFill(child);
-            mRenders.push_back(element);
-        }
-        else if (type == "action")
-        {
-            GUIAction* element = new GUIAction(child);
-            mActions.push_back(element);
-        }
-        else if (type == "console")
-        {
-            GUIConsole* element = new GUIConsole(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
-        else if (type == "button")
-        {
-            GUIButton* element = new GUIButton(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
-        else if (type == "checkbox")
-        {
-            GUICheckbox* element = new GUICheckbox(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
-        else if (type == "fileselector")
-        {
-            GUIFileSelector* element = new GUIFileSelector(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
-        else if (type == "animation")
-        {
-            GUIAnimation* element = new GUIAnimation(child);
-            mRenders.push_back(element);
-        }
-        else if (type == "progressbar")
-        {
-            GUIProgressBar* element = new GUIProgressBar(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
+		if (type == "text")
+		{
+			GUIText* element = new GUIText(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
+		else if (type == "image")
+		{
+			GUIImage* element = new GUIImage(child);
+			mRenders.push_back(element);
+		}
+		else if (type == "fill")
+		{
+			GUIFill* element = new GUIFill(child);
+			mRenders.push_back(element);
+		}
+		else if (type == "action")
+		{
+			GUIAction* element = new GUIAction(child);
+			mActions.push_back(element);
+		}
+		else if (type == "console")
+		{
+			GUIConsole* element = new GUIConsole(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
+		else if (type == "button")
+		{
+			GUIButton* element = new GUIButton(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
+		else if (type == "checkbox")
+		{
+			GUICheckbox* element = new GUICheckbox(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
+		else if (type == "fileselector")
+		{
+			GUIFileSelector* element = new GUIFileSelector(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
+		else if (type == "animation")
+		{
+			GUIAnimation* element = new GUIAnimation(child);
+			mRenders.push_back(element);
+		}
+		else if (type == "progressbar")
+		{
+			GUIProgressBar* element = new GUIProgressBar(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
 		else if (type == "slider")
-        {
-            GUISlider* element = new GUISlider(child);
-            mRenders.push_back(element);
-            mActions.push_back(element);
-        }
+		{
+			GUISlider* element = new GUISlider(child);
+			mRenders.push_back(element);
+			mActions.push_back(element);
+		}
 		else if (type == "slidervalue")
 		{
 			GUISliderValue *element = new GUISliderValue(child);
@@ -306,627 +309,651 @@
 			mRenders.push_back(element);
 			mActions.push_back(element);
 		}
-        else if (type == "template")
-        {
-            if (!templates || !child->first_attribute("name"))
-            {
-                LOGERR("Invalid template request.\n");
-            }
-            else
-            {
-                std::string name = child->first_attribute("name")->value();
+		else if (type == "template")
+		{
+			if (!templates || !child->first_attribute("name"))
+			{
+				LOGERR("Invalid template request.\n");
+			}
+			else
+			{
+				std::string name = child->first_attribute("name")->value();
 
-                // We need to find the correct template
-                xml_node<>* node;
-                node = templates->first_node("template");
+				// We need to find the correct template
+				xml_node<>* node;
+				node = templates->first_node("template");
 
-                while (node)
-                {
-                    if (!node->first_attribute("name"))
-                        continue;
+				while (node)
+				{
+					if (!node->first_attribute("name"))
+						continue;
 
-                    if (name == node->first_attribute("name")->value())
-                    {
-                        if (!ProcessNode(node, templates, depth + 1))
-                            return false;
-                        else
-                            break;
-                    }
-                    node = node->next_sibling("template");
-                }
-            }
-        }
-        else
-        {
-            LOGERR("Unknown object type.\n");
-        }
-        child = child->next_sibling("object");
-    }
-    return true;
+					if (name == node->first_attribute("name")->value())
+					{
+						if (!ProcessNode(node, templates, depth + 1))
+							return false;
+						else
+							break;
+					}
+					node = node->next_sibling("template");
+				}
+			}
+		}
+		else
+		{
+			LOGERR("Unknown object type.\n");
+		}
+		child = child->next_sibling("object");
+	}
+	return true;
 }
 
 int Page::Render(void)
 {
-    // Render background
-    gr_color(mBackground.red, mBackground.green, mBackground.blue, mBackground.alpha);
-    gr_fill(0, 0, gr_fb_width(), gr_fb_height());
+	// Render background
+	gr_color(mBackground.red, mBackground.green, mBackground.blue, mBackground.alpha);
+	gr_fill(0, 0, gr_fb_width(), gr_fb_height());
 
-    // Render remaining objects
-    std::vector<RenderObject*>::iterator iter;
-    for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
-    {
-        if ((*iter)->Render())
-            LOGERR("A render request has failed.\n");
-    }
-    return 0;
+	// Render remaining objects
+	std::vector<RenderObject*>::iterator iter;
+	for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
+	{
+		if ((*iter)->Render())
+			LOGERR("A render request has failed.\n");
+	}
+	return 0;
 }
 
 int Page::Update(void)
 {
-    int retCode = 0;
+	int retCode = 0;
 
-    std::vector<RenderObject*>::iterator iter;
-    for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
-    {
-        int ret = (*iter)->Update();
-        if (ret < 0)
-            LOGERR("An update request has failed.\n");
-        else if (ret > retCode)
-            retCode = ret;
-    }
+	std::vector<RenderObject*>::iterator iter;
+	for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
+	{
+		int ret = (*iter)->Update();
+		if (ret < 0)
+			LOGERR("An update request has failed.\n");
+		else if (ret > retCode)
+			retCode = ret;
+	}
 
-    return retCode;
+	return retCode;
 }
 
 int Page::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    // By default, return 1 to ignore further touches if nobody is listening
-    int ret = 1;
+	// By default, return 1 to ignore further touches if nobody is listening
+	int ret = 1;
 
-    // Don't try to handle a lack of handlers
-    if (mActions.size() == 0)   return ret;
+	// Don't try to handle a lack of handlers
+	if (mActions.size() == 0)
+		return ret;
 
-    // We record mTouchStart so we can pass all the touch stream to the same handler
-    if (state == TOUCH_START)
-    {
-        std::vector<ActionObject*>::reverse_iterator iter;
-        // We work backwards, from top-most element to bottom-most element
-        for (iter = mActions.rbegin(); iter != mActions.rend(); iter++)
-        {
-            if ((*iter)->IsInRegion(x, y))
-            {
-                mTouchStart = (*iter);
-                ret = mTouchStart->NotifyTouch(state, x, y);
-                if (ret >= 0)   break;
-                mTouchStart = NULL;
-            }
-        }
-    }
-    else if (state == TOUCH_RELEASE && mTouchStart != NULL)
-    {
-        ret = mTouchStart->NotifyTouch(state, x, y);
-        mTouchStart = NULL;
-    }
-    else if ((state == TOUCH_DRAG || state == TOUCH_HOLD || state == TOUCH_REPEAT) && mTouchStart != NULL)
-    {
-        ret = mTouchStart->NotifyTouch(state, x, y);
-    }
-    return ret;
+	// We record mTouchStart so we can pass all the touch stream to the same handler
+	if (state == TOUCH_START)
+	{
+		std::vector<ActionObject*>::reverse_iterator iter;
+		// We work backwards, from top-most element to bottom-most element
+		for (iter = mActions.rbegin(); iter != mActions.rend(); iter++)
+		{
+			if ((*iter)->IsInRegion(x, y))
+			{
+				mTouchStart = (*iter);
+				ret = mTouchStart->NotifyTouch(state, x, y);
+				if (ret >= 0)
+					break;
+				mTouchStart = NULL;
+			}
+		}
+	}
+	else if (state == TOUCH_RELEASE && mTouchStart != NULL)
+	{
+		ret = mTouchStart->NotifyTouch(state, x, y);
+		mTouchStart = NULL;
+	}
+	else if ((state == TOUCH_DRAG || state == TOUCH_HOLD || state == TOUCH_REPEAT) && mTouchStart != NULL)
+	{
+		ret = mTouchStart->NotifyTouch(state, x, y);
+	}
+	return ret;
 }
 
 int Page::NotifyKey(int key)
 {
-    std::vector<ActionObject*>::reverse_iterator iter;
+	std::vector<ActionObject*>::reverse_iterator iter;
 
-    // Don't try to handle a lack of handlers
-    if (mActions.size() == 0)   return 1;
+	// Don't try to handle a lack of handlers
+	if (mActions.size() == 0)
+		return 1;
 
-    // We work backwards, from top-most element to bottom-most element
-    for (iter = mActions.rbegin(); iter != mActions.rend(); iter++)
-    {
-        int ret = (*iter)->NotifyKey(key);
-        if (ret == 0)
-            return 0;
-        else if (ret < 0)
-            LOGERR("An action handler has returned an error");
-    }
-    return 1;
+	// We work backwards, from top-most element to bottom-most element
+	for (iter = mActions.rbegin(); iter != mActions.rend(); iter++)
+	{
+		int ret = (*iter)->NotifyKey(key);
+		if (ret == 0)
+			return 0;
+		else if (ret < 0)
+			LOGERR("An action handler has returned an error");
+	}
+	return 1;
 }
 
 int Page::NotifyKeyboard(int key)
 {
-    std::vector<InputObject*>::reverse_iterator iter;
+	std::vector<InputObject*>::reverse_iterator iter;
 
-    // Don't try to handle a lack of handlers
-    if (mInputs.size() == 0)   return 1;
+	// Don't try to handle a lack of handlers
+	if (mInputs.size() == 0)
+		return 1;
 
-    // We work backwards, from top-most element to bottom-most element
-    for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++)
-    {
-        int ret = (*iter)->NotifyKeyboard(key);
-        if (ret == 0)
-            return 0;
-        else if (ret < 0)
-            LOGERR("A keyboard handler has returned an error");
-    }
-    return 1;
+	// We work backwards, from top-most element to bottom-most element
+	for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++)
+	{
+		int ret = (*iter)->NotifyKeyboard(key);
+		if (ret == 0)
+			return 0;
+		else if (ret < 0)
+			LOGERR("A keyboard handler has returned an error");
+	}
+	return 1;
 }
 
 int Page::SetKeyBoardFocus(int inFocus)
 {
-    std::vector<InputObject*>::reverse_iterator iter;
+	std::vector<InputObject*>::reverse_iterator iter;
 
-    // Don't try to handle a lack of handlers
-    if (mInputs.size() == 0)   return 1;
+	// Don't try to handle a lack of handlers
+	if (mInputs.size() == 0)
+		return 1;
 
-    // We work backwards, from top-most element to bottom-most element
-    for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++)
-    {
-        int ret = (*iter)->SetInputFocus(inFocus);
-        if (ret == 0)
-            return 0;
-        else if (ret < 0)
-            LOGERR("An input focus handler has returned an error");
-    }
-    return 1;
+	// We work backwards, from top-most element to bottom-most element
+	for (iter = mInputs.rbegin(); iter != mInputs.rend(); iter++)
+	{
+		int ret = (*iter)->SetInputFocus(inFocus);
+		if (ret == 0)
+			return 0;
+		else if (ret < 0)
+			LOGERR("An input focus handler has returned an error");
+	}
+	return 1;
 }
 
 void Page::SetPageFocus(int inFocus)
 {
-    // Render remaining objects
-    std::vector<RenderObject*>::iterator iter;
-    for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
-    {
-        (*iter)->SetPageFocus(inFocus);
-    }
-    return;
+	// Render remaining objects
+	std::vector<RenderObject*>::iterator iter;
+	for (iter = mRenders.begin(); iter != mRenders.end(); iter++)
+		(*iter)->SetPageFocus(inFocus);
+
+	return;
 }
 
 int Page::NotifyVarChange(std::string varName, std::string value)
 {
-    std::vector<ActionObject*>::iterator iter;
+	std::vector<ActionObject*>::iterator iter;
 
-    // Don't try to handle a lack of handlers
-    if (mActions.size() == 0)   return 1;
+	// Don't try to handle a lack of handlers
+	if (mActions.size() == 0)
+		return 1;
 
-    for (iter = mActions.begin(); iter != mActions.end(); ++iter)
-    {
-        if ((*iter)->NotifyVarChange(varName, value))
-            LOGERR("An action handler errored on NotifyVarChange.\n");
-    }
-    return 0;
+	for (iter = mActions.begin(); iter != mActions.end(); ++iter)
+	{
+		if ((*iter)->NotifyVarChange(varName, value))
+			LOGERR("An action handler errored on NotifyVarChange.\n");
+	}
+	return 0;
 }
 
 PageSet::PageSet(char* xmlFile)
 {
-    mResources = NULL;
-    mCurrentPage = NULL;
-    mOverlayPage = NULL;
+	mResources = NULL;
+	mCurrentPage = NULL;
+	mOverlayPage = NULL;
 
-    mXmlFile = xmlFile;
-    if (xmlFile)
-        mDoc.parse<0>(mXmlFile);
-    else
-        mCurrentPage = new Page(NULL);
+	mXmlFile = xmlFile;
+	if (xmlFile)
+		mDoc.parse<0>(mXmlFile);
+	else
+		mCurrentPage = new Page(NULL);
 }
 
 PageSet::~PageSet()
 {
-    delete mResources;
-    free(mXmlFile);
+	delete mResources;
+	free(mXmlFile);
 }
 
 int PageSet::Load(ZipArchive* package)
 {
-    xml_node<>* parent;
-    xml_node<>* child;
-    xml_node<>* templates;
+	xml_node<>* parent;
+	xml_node<>* child;
+	xml_node<>* templates;
  
-    parent = mDoc.first_node("recovery");
-    if (!parent)
-        parent = mDoc.first_node("install");
+	parent = mDoc.first_node("recovery");
+	if (!parent)
+		parent = mDoc.first_node("install");
 
-    // Now, let's parse the XML
-    LOGINFO("Loading resources...\n");
-    child = parent->first_node("resources");
-    if (child)
-        mResources = new ResourceManager(child, package);
+	// Now, let's parse the XML
+	LOGINFO("Loading resources...\n");
+	child = parent->first_node("resources");
+	if (child)
+		mResources = new ResourceManager(child, package);
 
-    LOGINFO("Loading variables...\n");
-    child = parent->first_node("variables");
-    if (child)
-        LoadVariables(child);
+	LOGINFO("Loading variables...\n");
+	child = parent->first_node("variables");
+	if (child)
+		LoadVariables(child);
 
-    LOGINFO("Loading pages...\n");
-    // This may be NULL if no templates are present
-    templates = parent->first_node("templates");
+	LOGINFO("Loading pages...\n");
+	// This may be NULL if no templates are present
+	templates = parent->first_node("templates");
 
-    child = parent->first_node("pages");
-    if (!child)
-        return -1;
+	child = parent->first_node("pages");
+	if (!child)
+		return -1;
 
-    return LoadPages(child, templates);
+	return LoadPages(child, templates);
 }
 
 int PageSet::SetPage(std::string page)
 {
-    Page* tmp = FindPage(page);
-    if (tmp)
-    {
-        if (mCurrentPage)   mCurrentPage->SetPageFocus(0);
-        mCurrentPage = tmp;
-        mCurrentPage->SetPageFocus(1);
-        mCurrentPage->NotifyVarChange("", "");
-        return 0;
-    }
-    else
-    {
-        LOGERR("Unable to locate page (%s)\n", page.c_str());
-    }
-    return -1;
+	Page* tmp = FindPage(page);
+	if (tmp)
+	{
+		if (mCurrentPage)   mCurrentPage->SetPageFocus(0);
+		mCurrentPage = tmp;
+		mCurrentPage->SetPageFocus(1);
+		mCurrentPage->NotifyVarChange("", "");
+		return 0;
+	}
+	else
+	{
+		LOGERR("Unable to locate page (%s)\n", page.c_str());
+	}
+	return -1;
 }
 
 int PageSet::SetOverlay(Page* page)
 {
-    if (mOverlayPage)   mOverlayPage->SetPageFocus(0);
-    mOverlayPage = page;
-    if (mOverlayPage)
-    {
-        mOverlayPage->SetPageFocus(1);
-        mOverlayPage->NotifyVarChange("", "");
-    }
-    return 0;
+	if (mOverlayPage)   mOverlayPage->SetPageFocus(0);
+	mOverlayPage = page;
+	if (mOverlayPage)
+	{
+		mOverlayPage->SetPageFocus(1);
+		mOverlayPage->NotifyVarChange("", "");
+	}
+	return 0;
 }
 
 Resource* PageSet::FindResource(std::string name)
 {
-    return mResources ? mResources->FindResource(name) : NULL;
+	return mResources ? mResources->FindResource(name) : NULL;
 }
 
 Page* PageSet::FindPage(std::string name)
 {
-    std::vector<Page*>::iterator iter;
+	std::vector<Page*>::iterator iter;
 
-    for (iter = mPages.begin(); iter != mPages.end(); iter++)
-    {
-        if (name == (*iter)->GetName())
-            return (*iter);
-    }
-    return NULL;
+	for (iter = mPages.begin(); iter != mPages.end(); iter++)
+	{
+		if (name == (*iter)->GetName())
+			return (*iter);
+	}
+	return NULL;
 }
 
 int PageSet::LoadVariables(xml_node<>* vars)
 {
-    xml_node<>* child;
+	xml_node<>* child;
 
-    child = vars->first_node("variable");
-    while (child)
-    {
-        if (!child->first_attribute("name"))
-            break;
-        if (!child->first_attribute("value"))
-            break;
+	child = vars->first_node("variable");
+	while (child)
+	{
+		if (!child->first_attribute("name"))
+			break;
+		if (!child->first_attribute("value"))
+			break;
 
-        DataManager::SetValue(child->first_attribute("name")->value(), child->first_attribute("value")->value());
-        child = child->next_sibling("variable");
-    }
-    return 0;
+		DataManager::SetValue(child->first_attribute("name")->value(), child->first_attribute("value")->value());
+		child = child->next_sibling("variable");
+	}
+	return 0;
 }
 
 int PageSet::LoadPages(xml_node<>* pages, xml_node<>* templates /* = NULL */)
 {
-    xml_node<>* child;
+	xml_node<>* child;
 
-    if (!pages)    return -1;
+	if (!pages)
+		return -1;
 
-    child = pages->first_node("page");
-    while (child != NULL)
-    {
-        Page* page = new Page(child, templates);
-        if (page->GetName().empty())
-        {
-            LOGERR("Unable to process load page\n");
-            delete page;
-        }
-        else
-        {
-            mPages.push_back(page);
-        }
-        child = child->next_sibling("page");
-    }
-    if (mPages.size() > 0)
-        return 0;
-    return -1;
+	child = pages->first_node("page");
+	while (child != NULL)
+	{
+		Page* page = new Page(child, templates);
+		if (page->GetName().empty())
+		{
+			LOGERR("Unable to process load page\n");
+			delete page;
+		}
+		else
+		{
+			mPages.push_back(page);
+		}
+		child = child->next_sibling("page");
+	}
+	if (mPages.size() > 0)
+		return 0;
+	return -1;
 }
 
 int PageSet::IsCurrentPage(Page* page)
 {
-    return ((mCurrentPage && mCurrentPage == page) ? 1 : 0);
+	return ((mCurrentPage && mCurrentPage == page) ? 1 : 0);
 }
 
 int PageSet::Render(void)
 {
-    int ret;
+	int ret;
 
-    ret = (mCurrentPage ? mCurrentPage->Render() : -1);
-    if (ret < 0)    return ret;
-    ret = (mOverlayPage ? mOverlayPage->Render() : -1);
-    return ret;
+	ret = (mCurrentPage ? mCurrentPage->Render() : -1);
+	if (ret < 0)
+		return ret;
+	ret = (mOverlayPage ? mOverlayPage->Render() : -1);
+	return ret;
 }
 
 int PageSet::Update(void)
 {
-    int ret;
+	int ret;
 
-    ret = (mCurrentPage ? mCurrentPage->Update() : -1);
-    if (ret < 0 || ret > 1)     return ret;
-    ret = (mOverlayPage ? mOverlayPage->Update() : -1);
-    return ret;
+	ret = (mCurrentPage ? mCurrentPage->Update() : -1);
+	if (ret < 0 || ret > 1)
+		return ret;
+	ret = (mOverlayPage ? mOverlayPage->Update() : -1);
+	return ret;
 }
 
 int PageSet::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    if (mOverlayPage)   return (mOverlayPage->NotifyTouch(state, x, y));
-    return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1);
+	if (mOverlayPage)
+		return (mOverlayPage->NotifyTouch(state, x, y));
+
+	return (mCurrentPage ? mCurrentPage->NotifyTouch(state, x, y) : -1);
 }
 
 int PageSet::NotifyKey(int key)
 {
-    if (mOverlayPage)   return (mOverlayPage->NotifyKey(key));
-    return (mCurrentPage ? mCurrentPage->NotifyKey(key) : -1);
+	if (mOverlayPage)
+		return (mOverlayPage->NotifyKey(key));
+
+	return (mCurrentPage ? mCurrentPage->NotifyKey(key) : -1);
 }
 
 int PageSet::NotifyKeyboard(int key)
 {
-    if (mOverlayPage)   return (mOverlayPage->NotifyKeyboard(key));
-    return (mCurrentPage ? mCurrentPage->NotifyKeyboard(key) : -1);
+	if (mOverlayPage)
+		return (mOverlayPage->NotifyKeyboard(key));
+
+	return (mCurrentPage ? mCurrentPage->NotifyKeyboard(key) : -1);
 }
 
 int PageSet::SetKeyBoardFocus(int inFocus)
 {
-    if (mOverlayPage)   return (mOverlayPage->SetKeyBoardFocus(inFocus));
-    return (mCurrentPage ? mCurrentPage->SetKeyBoardFocus(inFocus) : -1);
+	if (mOverlayPage)
+		return (mOverlayPage->SetKeyBoardFocus(inFocus));
+
+	return (mCurrentPage ? mCurrentPage->SetKeyBoardFocus(inFocus) : -1);
 }
 
 int PageSet::NotifyVarChange(std::string varName, std::string value)
 {
-    if (mOverlayPage)   mOverlayPage->NotifyVarChange(varName, value);
-    return (mCurrentPage ? mCurrentPage->NotifyVarChange(varName, value) : -1);
+	if (mOverlayPage)
+		mOverlayPage->NotifyVarChange(varName, value);
+
+	return (mCurrentPage ? mCurrentPage->NotifyVarChange(varName, value) : -1);
 }
 
 int PageManager::LoadPackage(std::string name, std::string package, std::string startpage)
 {
-    int fd;
-    ZipArchive zip, *pZip = NULL;
-    long len;
-    char* xmlFile = NULL;
-    PageSet* pageSet = NULL;
-    int ret;
+	int fd;
+	ZipArchive zip, *pZip = NULL;
+	long len;
+	char* xmlFile = NULL;
+	PageSet* pageSet = NULL;
+	int ret;
 
-    // Open the XML file
-    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...
-        struct stat st;
-        if(stat(package.c_str(),&st) != 0)
-            return -1;
+	// Open the XML file
+	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...
+		struct stat st;
+		if(stat(package.c_str(),&st) != 0)
+			return -1;
 
-        len = st.st_size;
-        xmlFile = (char*) malloc(len + 1);
-        if (!xmlFile)       return -1;
+		len = st.st_size;
+		xmlFile = (char*) malloc(len + 1);
+		if (!xmlFile)
+			return -1;
 
-        fd = open(package.c_str(), O_RDONLY);
-        if (fd == -1)       goto error;
+		fd = open(package.c_str(), O_RDONLY);
+		if (fd == -1)
+			goto error;
 
-        read(fd, xmlFile, len);
-        close(fd);
-    }
-    else
-    {
-        pZip = &zip;
-        const ZipEntry* ui_xml = mzFindZipEntry(&zip, "ui.xml");
-        if (ui_xml == NULL)
-        {
-            LOGERR("Unable to locate ui.xml in zip file\n");
-            goto error;
-        }
-    
-        // Allocate the buffer for the file
-        len = mzGetZipEntryUncompLen(ui_xml);
-        xmlFile = (char*) malloc(len + 1);
-        if (!xmlFile)        goto error;
-    
-        if (!mzExtractZipEntryToBuffer(&zip, ui_xml, (unsigned char*) xmlFile))
-        {
-            LOGERR("Unable to extract ui.xml\n");
-            goto error;
-        }
-    }
-
-    // NULL-terminate the string
-    xmlFile[len] = 0x00;
-
-    // Before loading, mCurrentSet must be the loading package so we can find resources
-    pageSet = mCurrentSet;
-    mCurrentSet = new PageSet(xmlFile);
-
-    ret = mCurrentSet->Load(pZip);
-    if (ret == 0)
-    {
-        mCurrentSet->SetPage(startpage);
-        mPageSets.insert(std::pair<std::string, PageSet*>(name, mCurrentSet));
-    }
-    else
-    {
-        LOGERR("Package %s failed to load.\n", name.c_str());
-    }
+		read(fd, xmlFile, len);
+		close(fd);
+	}
+	else
+	{
+		pZip = &zip;
+		const ZipEntry* ui_xml = mzFindZipEntry(&zip, "ui.xml");
+		if (ui_xml == NULL)
+		{
+			LOGERR("Unable to locate ui.xml in zip file\n");
+			goto error;
+		}
 	
-    // The first successful package we loaded is the base
-    if (mBaseSet == NULL)
-        mBaseSet = mCurrentSet;
+		// Allocate the buffer for the file
+		len = mzGetZipEntryUncompLen(ui_xml);
+		xmlFile = (char*) malloc(len + 1);
+		if (!xmlFile)
+			goto error;
+	
+		if (!mzExtractZipEntryToBuffer(&zip, ui_xml, (unsigned char*) xmlFile))
+		{
+			LOGERR("Unable to extract ui.xml\n");
+			goto error;
+		}
+	}
 
-    mCurrentSet = pageSet;
+	// NULL-terminate the string
+	xmlFile[len] = 0x00;
 
-    if (pZip)   mzCloseZipArchive(pZip);
-    return ret;
+	// Before loading, mCurrentSet must be the loading package so we can find resources
+	pageSet = mCurrentSet;
+	mCurrentSet = new PageSet(xmlFile);
+
+	ret = mCurrentSet->Load(pZip);
+	if (ret == 0)
+	{
+		mCurrentSet->SetPage(startpage);
+		mPageSets.insert(std::pair<std::string, PageSet*>(name, mCurrentSet));
+	}
+	else
+	{
+		LOGERR("Package %s failed to load.\n", name.c_str());
+	}
+	
+	// The first successful package we loaded is the base
+	if (mBaseSet == NULL)
+		mBaseSet = mCurrentSet;
+
+	mCurrentSet = pageSet;
+
+	if (pZip)
+		mzCloseZipArchive(pZip);
+	return ret;
 
 error:
-    LOGERR("An internal error has occurred.\n");
-    if (pZip)       mzCloseZipArchive(pZip);
-    if (xmlFile)    free(xmlFile);
-    return -1;
+	LOGERR("An internal error has occurred.\n");
+	if (pZip)
+		mzCloseZipArchive(pZip);
+	if (xmlFile)
+		free(xmlFile);
+	return -1;
 }
 
 PageSet* PageManager::FindPackage(std::string name)
 {
-    std::map<std::string, PageSet*>::iterator iter;
+	std::map<std::string, PageSet*>::iterator iter;
 
-    iter = mPageSets.find(name);
-    if (iter != mPageSets.end())
-    {
-        return (*iter).second;
-    }
-    LOGERR("Unable to locate package %s\n", name.c_str());
-    return NULL;
+	iter = mPageSets.find(name);
+	if (iter != mPageSets.end())
+		return (*iter).second;
+
+	LOGERR("Unable to locate package %s\n", name.c_str());
+	return NULL;
 }
 
 PageSet* PageManager::SelectPackage(std::string name)
 {
-    LOGINFO("Switching packages (%s)\n", name.c_str());
-    PageSet* tmp;
+	LOGINFO("Switching packages (%s)\n", name.c_str());
+	PageSet* tmp;
 
-    tmp = FindPackage(name);
-    if (tmp)
-        mCurrentSet = tmp;
-    else
-        LOGERR("Unable to find package.\n");
+	tmp = FindPackage(name);
+	if (tmp)
+		mCurrentSet = tmp;
+	else
+		LOGERR("Unable to find package.\n");
 
-    return mCurrentSet;
+	return mCurrentSet;
 }
 
 int PageManager::ReloadPackage(std::string name, std::string package)
 {
-    std::map<std::string, PageSet*>::iterator iter;
+	std::map<std::string, PageSet*>::iterator iter;
 
-    iter = mPageSets.find(name);
-    if (iter == mPageSets.end())
-        return -1;
+	iter = mPageSets.find(name);
+	if (iter == mPageSets.end())
+		return -1;
 
-    PageSet* set = (*iter).second;
-    mPageSets.erase(iter);
+	PageSet* set = (*iter).second;
+	mPageSets.erase(iter);
 
-    if (LoadPackage(name, package, "main") != 0)
-    {
-        LOGERR("Failed to load package.\n");
-        mPageSets.insert(std::pair<std::string, PageSet*>(name, set));
-        return -1;
-    }
-    if (mCurrentSet == set)     SelectPackage(name);
-    delete set;
-    return 0;
+	if (LoadPackage(name, package, "main") != 0)
+	{
+		LOGERR("Failed to load package.\n");
+		mPageSets.insert(std::pair<std::string, PageSet*>(name, set));
+		return -1;
+	}
+	if (mCurrentSet == set)
+		SelectPackage(name);
+	delete set;
+	return 0;
 }
 
 void PageManager::ReleasePackage(std::string name)
 {
-    std::map<std::string, PageSet*>::iterator iter;
+	std::map<std::string, PageSet*>::iterator iter;
 
-    iter = mPageSets.find(name);
-    if (iter == mPageSets.end())
-        return;
+	iter = mPageSets.find(name);
+	if (iter == mPageSets.end())
+		return;
 
-    PageSet* set = (*iter).second;
-    mPageSets.erase(iter);
-    delete set;
-    return;
+	PageSet* set = (*iter).second;
+	mPageSets.erase(iter);
+	delete set;
+	return;
 }
 
 int PageManager::ChangePage(std::string name)
 {
-    DataManager::SetValue("tw_operation_state", 0);
-    int ret = (mCurrentSet ? mCurrentSet->SetPage(name) : -1);
-    return ret;
+	DataManager::SetValue("tw_operation_state", 0);
+	int ret = (mCurrentSet ? mCurrentSet->SetPage(name) : -1);
+	return ret;
 }
 
 int PageManager::ChangeOverlay(std::string name)
 {
-    if (name.empty())
-        return mCurrentSet->SetOverlay(NULL);
-    else
-    {
-        Page* page = mBaseSet ? mBaseSet->FindPage(name) : NULL;
-        return mCurrentSet->SetOverlay(page);
-    }
+	if (name.empty())
+		return mCurrentSet->SetOverlay(NULL);
+	else
+	{
+		Page* page = mBaseSet ? mBaseSet->FindPage(name) : NULL;
+		return mCurrentSet->SetOverlay(page);
+	}
 }
 
 Resource* PageManager::FindResource(std::string name)
 {
-    return (mCurrentSet ? mCurrentSet->FindResource(name) : NULL);
+	return (mCurrentSet ? mCurrentSet->FindResource(name) : NULL);
 }
 
 Resource* PageManager::FindResource(std::string package, std::string name)
 {
-    PageSet* tmp;
+	PageSet* tmp;
 
-    tmp = FindPackage(name);
-    return (tmp ? tmp->FindResource(name) : NULL);
+	tmp = FindPackage(name);
+	return (tmp ? tmp->FindResource(name) : NULL);
 }
 
 int PageManager::SwitchToConsole(void)
 {
-    PageSet* console = new PageSet(NULL);
+	PageSet* console = new PageSet(NULL);
 
-    mCurrentSet = console;
-    return 0;
+	mCurrentSet = console;
+	return 0;
 }
 
 int PageManager::IsCurrentPage(Page* page)
 {
-    return (mCurrentSet ? mCurrentSet->IsCurrentPage(page) : 0);
+	return (mCurrentSet ? mCurrentSet->IsCurrentPage(page) : 0);
 }
 
 int PageManager::Render(void)
 {
-    return (mCurrentSet ? mCurrentSet->Render() : -1);
+	return (mCurrentSet ? mCurrentSet->Render() : -1);
 }
 
 int PageManager::Update(void)
 {
-    if(blankTimer.IsScreenOff())
-        return 0;
+	if(blankTimer.IsScreenOff())
+		return 0;
 
-    return (mCurrentSet ? mCurrentSet->Update() : -1);
+	return (mCurrentSet ? mCurrentSet->Update() : -1);
 }
 
 int PageManager::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    return (mCurrentSet ? mCurrentSet->NotifyTouch(state, x, y) : -1);
+	return (mCurrentSet ? mCurrentSet->NotifyTouch(state, x, y) : -1);
 }
 
 int PageManager::NotifyKey(int key)
 {
-    return (mCurrentSet ? mCurrentSet->NotifyKey(key) : -1);
+	return (mCurrentSet ? mCurrentSet->NotifyKey(key) : -1);
 }
 
 int PageManager::NotifyKeyboard(int key)
 {
-    return (mCurrentSet ? mCurrentSet->NotifyKeyboard(key) : -1);
+	return (mCurrentSet ? mCurrentSet->NotifyKeyboard(key) : -1);
 }
 
 int PageManager::SetKeyBoardFocus(int inFocus)
 {
-    return (mCurrentSet ? mCurrentSet->SetKeyBoardFocus(inFocus) : -1);
+	return (mCurrentSet ? mCurrentSet->SetKeyBoardFocus(inFocus) : -1);
 }
 
 int PageManager::NotifyVarChange(std::string varName, std::string value)
 {
-    return (mCurrentSet ? mCurrentSet->NotifyVarChange(varName, value) : -1);
+	return (mCurrentSet ? mCurrentSet->NotifyVarChange(varName, value) : -1);
 }
 
 extern "C" void gui_notifyVarChange(const char *name, const char* value)
 {
-    if (!gGuiRunning)   return;
+	if (!gGuiRunning)
+		return;
 
-    PageManager::NotifyVarChange(name, value);
+	PageManager::NotifyVarChange(name, value);
 }
-
diff --git a/gui/pages.hpp b/gui/pages.hpp
index 2c71735..c308c1a 100644
--- a/gui/pages.hpp
+++ b/gui/pages.hpp
@@ -4,10 +4,10 @@
 #define _PAGES_HEADER_HPP
 
 typedef struct {
-    unsigned char red;
-    unsigned char green;
-    unsigned char blue;
-    unsigned char alpha;
+	unsigned char red;
+	unsigned char green;
+	unsigned char blue;
+	unsigned char alpha;
 } COLOR;
 
 // Utility Functions
@@ -26,110 +26,110 @@
 class Page
 {
 public:
-    virtual ~Page()             {}
+	virtual ~Page() {}
 
 public:
-    Page(xml_node<>* page, xml_node<>* templates = NULL);
-    std::string GetName(void)   { return mName; }
+	Page(xml_node<>* page, xml_node<>* templates = NULL);
+	std::string GetName(void)   { return mName; }
 
 public:
-    virtual int Render(void);
-    virtual int Update(void);
-    virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
-    virtual int NotifyKey(int key);
+	virtual int Render(void);
+	virtual int Update(void);
+	virtual int NotifyTouch(TOUCH_STATE state, int x, int y);
+	virtual int NotifyKey(int key);
 	virtual int NotifyKeyboard(int key);
 	virtual int SetKeyBoardFocus(int inFocus);
-    virtual int NotifyVarChange(std::string varName, std::string value);
-    virtual void SetPageFocus(int inFocus);
+	virtual int NotifyVarChange(std::string varName, std::string value);
+	virtual void SetPageFocus(int inFocus);
 
 protected:
-    std::string mName;
-    std::vector<RenderObject*> mRenders;
-    std::vector<ActionObject*> mActions;
+	std::string mName;
+	std::vector<RenderObject*> mRenders;
+	std::vector<ActionObject*> mActions;
 	std::vector<InputObject*> mInputs;
 
-    ActionObject* mTouchStart;
-    COLOR mBackground;
+	ActionObject* mTouchStart;
+	COLOR mBackground;
 
 protected:
-    bool ProcessNode(xml_node<>* page, xml_node<>* templates = NULL, int depth = 0);
+	bool ProcessNode(xml_node<>* page, xml_node<>* templates = NULL, int depth = 0);
 };
 
 class PageSet
 {
 public:
-    PageSet(char* xmlFile);
-    virtual ~PageSet();
+	PageSet(char* xmlFile);
+	virtual ~PageSet();
 
 public:
-    int Load(ZipArchive* package);
+	int Load(ZipArchive* package);
 
-    Page* FindPage(std::string name);
-    int SetPage(std::string page);
+	Page* FindPage(std::string name);
+	int SetPage(std::string page);
 	int SetOverlay(Page* page);
-    Resource* FindResource(std::string name);
+	Resource* FindResource(std::string name);
 
-    // Helper routine for identifing if we're the current page
-    int IsCurrentPage(Page* page);
+	// Helper routine for identifing if we're the current page
+	int IsCurrentPage(Page* page);
 
-    // These are routing routines
-    int Render(void);
-    int Update(void);
-    int NotifyTouch(TOUCH_STATE state, int x, int y);
-    int NotifyKey(int key);
+	// These are routing routines
+	int Render(void);
+	int Update(void);
+	int NotifyTouch(TOUCH_STATE state, int x, int y);
+	int NotifyKey(int key);
 	int NotifyKeyboard(int key);
 	int SetKeyBoardFocus(int inFocus);
-    int NotifyVarChange(std::string varName, std::string value);
+	int NotifyVarChange(std::string varName, std::string value);
 
 protected:
-    int LoadPages(xml_node<>* pages, xml_node<>* templates = NULL);
-    int LoadVariables(xml_node<>* vars);
+	int LoadPages(xml_node<>* pages, xml_node<>* templates = NULL);
+	int LoadVariables(xml_node<>* vars);
 
 protected:
-    char* mXmlFile;
-    xml_document<> mDoc;
-    ResourceManager* mResources;
-    std::vector<Page*> mPages;
-    Page* mCurrentPage;
-	Page* mOverlayPage;     // This is a special case, used for "locking" the screen
+	char* mXmlFile;
+	xml_document<> mDoc;
+	ResourceManager* mResources;
+	std::vector<Page*> mPages;
+	Page* mCurrentPage;
+	Page* mOverlayPage; // This is a special case, used for "locking" the screen
 };
 
 class PageManager
 {
 public:
-    // Used by GUI
-    static int LoadPackage(std::string name, std::string package, std::string startpage);
-    static PageSet* SelectPackage(std::string name);
-    static int ReloadPackage(std::string name, std::string package);
-    static void ReleasePackage(std::string name);
+	// Used by GUI
+	static int LoadPackage(std::string name, std::string package, std::string startpage);
+	static PageSet* SelectPackage(std::string name);
+	static int ReloadPackage(std::string name, std::string package);
+	static void ReleasePackage(std::string name);
 
-    // Used for actions and pages
-    static int ChangePage(std::string name);
+	// Used for actions and pages
+	static int ChangePage(std::string name);
 	static int ChangeOverlay(std::string name);
-    static Resource* FindResource(std::string name);
-    static Resource* FindResource(std::string package, std::string name);
+	static Resource* FindResource(std::string name);
+	static Resource* FindResource(std::string package, std::string name);
 
-    // Used for console-only mode - Can be reverted via ChangePage
-    static int SwitchToConsole(void);
+	// Used for console-only mode - Can be reverted via ChangePage
+	static int SwitchToConsole(void);
 
-    // Helper to identify if a particular page is the active page
-    static int IsCurrentPage(Page* page);
+	// Helper to identify if a particular page is the active page
+	static int IsCurrentPage(Page* page);
 
-    // These are routing routines
-    static int Render(void);
-    static int Update(void);
-    static int NotifyTouch(TOUCH_STATE state, int x, int y);
-    static int NotifyKey(int key);
+	// These are routing routines
+	static int Render(void);
+	static int Update(void);
+	static int NotifyTouch(TOUCH_STATE state, int x, int y);
+	static int NotifyKey(int key);
 	static int NotifyKeyboard(int key);
 	static int SetKeyBoardFocus(int inFocus);
-    static int NotifyVarChange(std::string varName, std::string value);
+	static int NotifyVarChange(std::string varName, std::string value);
 
 protected:
-    static PageSet* FindPackage(std::string name);
+	static PageSet* FindPackage(std::string name);
 
 protected:
-    static std::map<std::string, PageSet*> mPageSets;
-    static PageSet* mCurrentSet;
+	static std::map<std::string, PageSet*> mPageSets;
+	static PageSet* mCurrentSet;
 	static PageSet* mBaseSet;
 };
 
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index 36d5c16..abe0a38 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -193,12 +193,12 @@
 
 		attr = child->first_attribute("highlightcolor");
 		memset(&mFontHighlightColor, 0, sizeof(COLOR));
-        if (attr)
-        {
-            std::string color = attr->value();
+		if (attr)
+		{
+			std::string color = attr->value();
 			ConvertStrToColor(color, &mFontHighlightColor);
 			hasFontHighlightColor = true;
-        }
+		}
 	}
 
 	// Load the separator if it exists
@@ -433,21 +433,21 @@
 		}
 
 		if (mList.at(line + mStart).selected != 0)
-        {
-            icon = mIconSelected;
+		{
+			icon = mIconSelected;
 			currentIconHeight = mSelectedIconHeight;
 			currentIconWidth = mSelectedIconWidth;
 			currentIconOffsetY = SelectedIconOffsetY;
 			currentIconOffsetX = SelectedIconOffsetX;
-        }
-        else
-        {
-            icon = mIconUnselected;
+		}
+		else
+		{
+			icon = mIconUnselected;
 			currentIconHeight = mSelectedIconHeight;
 			currentIconWidth = mSelectedIconWidth;
 			currentIconOffsetY = SelectedIconOffsetY;
 			currentIconOffsetX = SelectedIconOffsetX;
-        }
+		}
 
 		if (icon && icon->GetResource())
 		{
@@ -827,8 +827,8 @@
 		}
 	}
 	if (varName == mVariable && !mUpdate)
-    {
-        if (ListType == "storage") {
+	{
+		if (ListType == "storage") {
 			int i, listSize = mList.size(), selected_index = 0;
 
 			currentValue = value;
@@ -856,8 +856,8 @@
 		}
 
 		mUpdate = 1;
-        return 0;
-    }
+		return 0;
+	}
 	return 0;
 }
 
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index dce4315..d53fdc1 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -27,188 +27,200 @@
 
 GUIProgressBar::GUIProgressBar(xml_node<>* node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mEmptyBar = NULL;
-    mFullBar = NULL;
-    mLastPos = 0;
-    mSlide = 0.0;
-    mSlideInc = 0.0;
+	mEmptyBar = NULL;
+	mFullBar = NULL;
+	mLastPos = 0;
+	mSlide = 0.0;
+	mSlideInc = 0.0;
 
-    if (!node)
-    {
-        LOGERR("GUIProgressBar created without XML node\n");
-        return;
-    }
+	if (!node)
+	{
+		LOGERR("GUIProgressBar created without XML node\n");
+		return;
+	}
 
-    child = node->first_node("resource");
-    if (child)
-    {
-        attr = child->first_attribute("empty");
-        if (attr)
-            mEmptyBar = PageManager::FindResource(attr->value());
+	child = node->first_node("resource");
+	if (child)
+	{
+		attr = child->first_attribute("empty");
+		if (attr)
+			mEmptyBar = PageManager::FindResource(attr->value());
 
-        attr = child->first_attribute("full");
-        if (attr)
-            mFullBar = PageManager::FindResource(attr->value());
-    }
+		attr = child->first_attribute("full");
+		if (attr)
+			mFullBar = PageManager::FindResource(attr->value());
+	}
 
-    // Load the placement
-    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY);
+	// Load the placement
+	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY);
 
-    // Load the data
-    child = node->first_node("data");
-    if (child)
-    {
-        attr = child->first_attribute("min");
-        if (attr)   mMinValVar = attr->value();
+	// Load the data
+	child = node->first_node("data");
+	if (child)
+	{
+		attr = child->first_attribute("min");
+		if (attr)   mMinValVar = attr->value();
 
-        attr = child->first_attribute("max");
-        if (attr)   mMaxValVar = attr->value();
+		attr = child->first_attribute("max");
+		if (attr)   mMaxValVar = attr->value();
 
-        attr = child->first_attribute("name");
-        if (attr)   mCurValVar = attr->value();
-    }
+		attr = child->first_attribute("name");
+		if (attr)   mCurValVar = attr->value();
+	}
 
-    if (mEmptyBar && mEmptyBar->GetResource())
-    {
-        mRenderW = gr_get_width(mEmptyBar->GetResource());
-        mRenderH = gr_get_height(mEmptyBar->GetResource());
-    }
+	if (mEmptyBar && mEmptyBar->GetResource())
+	{
+		mRenderW = gr_get_width(mEmptyBar->GetResource());
+		mRenderH = gr_get_height(mEmptyBar->GetResource());
+	}
 
-    return;
+	return;
 }
 
 int GUIProgressBar::Render(void)
 {
-    // This handles making sure timing updates occur
-    Update();
-    return RenderInternal();
+	// This handles making sure timing updates occur
+	Update();
+	return RenderInternal();
 }
 
 int GUIProgressBar::RenderInternal(void)
 {
-    if (!mEmptyBar || !mEmptyBar->GetResource())    return -1;
-    if (!mFullBar || !mFullBar->GetResource())      return -1;
+	if (!mEmptyBar || !mEmptyBar->GetResource())
+		return -1;
 
-    gr_blit(mEmptyBar->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
-    gr_blit(mFullBar->GetResource(), 0, 0, mLastPos, mRenderH, mRenderX, mRenderY);
-    return 0;
+	if (!mFullBar || !mFullBar->GetResource())
+		return -1;
+
+	gr_blit(mEmptyBar->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
+	gr_blit(mFullBar->GetResource(), 0, 0, mLastPos, mRenderH, mRenderX, mRenderY);
+	return 0;
 }
 
 int GUIProgressBar::Update(void)
 {
-    std::string str;
-    int min, max, cur, pos;
+	std::string str;
+	int min, max, cur, pos;
 
-    if (mMinValVar.empty())     min = 0;
-    else
-    {
-        str.clear();
-        if (atoi(mMinValVar.c_str()) != 0)      str = mMinValVar;
-        else                                    DataManager::GetValue(mMinValVar, str);
-        min = atoi(str.c_str());
-    }
+	if (mMinValVar.empty())
+		min = 0;
+	else
+	{
+		str.clear();
+		if (atoi(mMinValVar.c_str()) != 0)
+			str = mMinValVar;
+		else
+			DataManager::GetValue(mMinValVar, str);
+		min = atoi(str.c_str());
+	}
 
-    if (mMaxValVar.empty())     max = 100;
-    else
-    {
-        str.clear();
-        if (atoi(mMaxValVar.c_str()) != 0)      str = mMaxValVar;
-        else                                    DataManager::GetValue(mMaxValVar, str);
-        max = atoi(str.c_str());
-    }
+	if (mMaxValVar.empty())
+		max = 100;
+	else
+	{
+		str.clear();
+		if (atoi(mMaxValVar.c_str()) != 0)
+			str = mMaxValVar;
+		else
+			DataManager::GetValue(mMaxValVar, str);
+		max = atoi(str.c_str());
+	}
 
-    str.clear();
-    DataManager::GetValue(mCurValVar, str);
-    cur = atoi(str.c_str());
+	str.clear();
+	DataManager::GetValue(mCurValVar, str);
+	cur = atoi(str.c_str());
 
-    // Do slide, if needed
-    if (mSlideFrames)
-    {
-        mSlide += mSlideInc;
-        mSlideFrames--;
-        if (cur != (int) mSlide)
-        {
-            cur = (int) mSlide;
-            DataManager::SetValue(mCurValVar, cur);
-        }
-    }
+	// Do slide, if needed
+	if (mSlideFrames)
+	{
+		mSlide += mSlideInc;
+		mSlideFrames--;
+		if (cur != (int) mSlide)
+		{
+			cur = (int) mSlide;
+			DataManager::SetValue(mCurValVar, cur);
+		}
+	}
 
-    // Normalize to 0
-    max -= min;
-    cur -= min;
-    min = 0;
+	// Normalize to 0
+	max -= min;
+	cur -= min;
+	min = 0;
 
-    if (cur < min)  cur = min;
-    if (cur > max)  cur = max;
+	if (cur < min)  cur = min;
+	if (cur > max)  cur = max;
 
-    if (max == 0)   pos = 0;
-    else            pos = (cur * mRenderW) / max;
+	if (max == 0)   pos = 0;
+	else            pos = (cur * mRenderW) / max;
 
-    if (pos == mLastPos)            return 0;
-    mLastPos = pos;
-    if (RenderInternal() != 0)      return -1;
-    return 2;
+	if (pos == mLastPos)
+		return 0;
+
+	mLastPos = pos;
+
+	if (RenderInternal() != 0)
+		return -1;
+	return 2;
 }
 
 int GUIProgressBar::NotifyVarChange(std::string varName, std::string value)
 {
-    static int nextPush = 0;
+	static int nextPush = 0;
 
-    if (varName.empty())
-    {
-        nextPush = 0;
-        mLastPos = 0;
-        mSlide = 0.0;
-        mSlideInc = 0.0;
-        return 0;
-    }
+	if (varName.empty())
+	{
+		nextPush = 0;
+		mLastPos = 0;
+		mSlide = 0.0;
+		mSlideInc = 0.0;
+		return 0;
+	}
 
-    if (varName == "ui_progress_portion" || varName == "ui_progress_frames")
-    {
-        std::string str;
-        int cur;
+	if (varName == "ui_progress_portion" || varName == "ui_progress_frames")
+	{
+		std::string str;
+		int cur;
 
-        if (mSlideFrames)
-        {
-            mSlide += (mSlideInc * mSlideFrames);
-            cur = (int) mSlide;
-            DataManager::SetValue(mCurValVar, cur);
-            mSlideFrames = 0;
-        }
+		if (mSlideFrames)
+		{
+			mSlide += (mSlideInc * mSlideFrames);
+			cur = (int) mSlide;
+			DataManager::SetValue(mCurValVar, cur);
+			mSlideFrames = 0;
+		}
 
-        if (nextPush)
-        {
-            mSlide += nextPush;
-            cur = (int) mSlide;
-            DataManager::SetValue(mCurValVar, cur);
-            nextPush = 0;
-        }
+		if (nextPush)
+		{
+			mSlide += nextPush;
+			cur = (int) mSlide;
+			DataManager::SetValue(mCurValVar, cur);
+			nextPush = 0;
+		}
 
-        if (varName == "ui_progress_portion")   mSlide = atof(value.c_str());
-        else
-        {
-            mSlideFrames = atol(value.c_str());
-            if (mSlideFrames == 0)
-            {
-                // We're just holding this progress until the next push
-                nextPush = mSlide;
-            }
-        }
+		if (varName == "ui_progress_portion")   mSlide = atof(value.c_str());
+		else
+		{
+			mSlideFrames = atol(value.c_str());
+			if (mSlideFrames == 0)
+			{
+				// We're just holding this progress until the next push
+				nextPush = mSlide;
+			}
+		}
 
-        if (mSlide > 0 && mSlideFrames > 0)
-        {
-            // Get the current position
-            str.clear();
-            DataManager::GetValue(mCurValVar, str);
-            cur = atoi(str.c_str());
+		if (mSlide > 0 && mSlideFrames > 0)
+		{
+			// Get the current position
+			str.clear();
+			DataManager::GetValue(mCurValVar, str);
+			cur = atoi(str.c_str());
 
-            mSlideInc = (float) mSlide / (float) mSlideFrames;
-            mSlide = cur;
-        }
-    }
-    return 0;
+			mSlideInc = (float) mSlide / (float) mSlideFrames;
+			mSlide = cur;
+		}
+	}
+	return 0;
 }
-
diff --git a/gui/resources.cpp b/gui/resources.cpp
index aaa1533..6babc57 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -32,59 +32,56 @@
 
 Resource::Resource(xml_node<>* node, ZipArchive* pZip)
 {
-    if (node && node->first_attribute("name"))
-        mName = node->first_attribute("name")->value();
+	if (node && node->first_attribute("name"))
+		mName = node->first_attribute("name")->value();
 }
 
-
-int Resource::ExtractResource(ZipArchive* pZip, 
-                              std::string folderName, 
-                              std::string fileName, 
-                              std::string fileExtn, 
-                              std::string destFile)
+int Resource::ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile)
 {
-    if (!pZip)  return -1;
+	if (!pZip)
+		return -1;
 
-    std::string src = folderName + "/" + fileName + fileExtn;
+	std::string src = folderName + "/" + fileName + fileExtn;
 
 	const ZipEntry* binary = mzFindZipEntry(pZip, src.c_str());
-    if (binary == NULL) {
-        return -1;
+	if (binary == NULL) {
+		return -1;
 	}
 
-    unlink(destFile.c_str());
-    int fd = creat(destFile.c_str(), 0666);
-    if (fd < 0)
-        return -1;
+	unlink(destFile.c_str());
+	int fd = creat(destFile.c_str(), 0666);
+	if (fd < 0)
+		return -1;
 
-    int ret = 0;
-    if (!mzExtractZipEntryToFile(pZip, binary, fd))
-        ret = -1;
+	int ret = 0;
+	if (!mzExtractZipEntryToFile(pZip, binary, fd))
+		ret = -1;
 
-    close(fd);
-    return ret;
+	close(fd);
+	return ret;
 }
 
 FontResource::FontResource(xml_node<>* node, ZipArchive* pZip)
  : Resource(node, pZip)
 {
-    std::string file;
+	std::string file;
 
-    mFont = NULL;
-    if (!node)  return;
+	mFont = NULL;
+	if (!node)
+		return;
 
-    if (node->first_attribute("filename"))
-        file = node->first_attribute("filename")->value();
+	if (node->first_attribute("filename"))
+		file = node->first_attribute("filename")->value();
 
-    if (ExtractResource(pZip, "fonts", file, ".dat", TMP_RESOURCE_NAME) == 0)
-    {
-        mFont = gr_loadFont(TMP_RESOURCE_NAME);
-        unlink(TMP_RESOURCE_NAME);
-    }
-    else
-    {
-        mFont = gr_loadFont(file.c_str());
-    }
+	if (ExtractResource(pZip, "fonts", file, ".dat", TMP_RESOURCE_NAME) == 0)
+	{
+		mFont = gr_loadFont(TMP_RESOURCE_NAME);
+		unlink(TMP_RESOURCE_NAME);
+	}
+	else
+	{
+		mFont = gr_loadFont(file.c_str());
+	}
 }
 
 FontResource::~FontResource()
@@ -94,115 +91,118 @@
 ImageResource::ImageResource(xml_node<>* node, ZipArchive* pZip)
  : Resource(node, pZip)
 {
-    std::string file;
+	std::string file;
 
-    mSurface = NULL;
-    if (!node)  return;
+	mSurface = NULL;
+	if (!node)
+		return;
 
-    if (node->first_attribute("filename"))
-        file = node->first_attribute("filename")->value();
+	if (node->first_attribute("filename"))
+		file = node->first_attribute("filename")->value();
 
-    if (ExtractResource(pZip, "images", file, ".png", TMP_RESOURCE_NAME) == 0)
-    {
-        res_create_surface(TMP_RESOURCE_NAME, &mSurface);
-        unlink(TMP_RESOURCE_NAME);
-    } else if (ExtractResource(pZip, "images", file, "", TMP_RESOURCE_NAME) == 0)
-    {
-        // JPG includes the .jpg extension in the filename so extension should be blank
+	if (ExtractResource(pZip, "images", file, ".png", TMP_RESOURCE_NAME) == 0)
+	{
 		res_create_surface(TMP_RESOURCE_NAME, &mSurface);
-        unlink(TMP_RESOURCE_NAME);
-    }
-    else
+		unlink(TMP_RESOURCE_NAME);
+	}
+	else if (ExtractResource(pZip, "images", file, "", TMP_RESOURCE_NAME) == 0)
+	{
+		// JPG includes the .jpg extension in the filename so extension should be blank
+		res_create_surface(TMP_RESOURCE_NAME, &mSurface);
+		unlink(TMP_RESOURCE_NAME);
+	}
+	else
 		res_create_surface(file.c_str(), &mSurface);
 }
 
 ImageResource::~ImageResource()
 {
-    if (mSurface)
-        res_free_surface(mSurface);
+	if (mSurface)
+		res_free_surface(mSurface);
 }
 
 AnimationResource::AnimationResource(xml_node<>* node, ZipArchive* pZip)
  : Resource(node, pZip)
 {
-    std::string file;
-    int fileNum = 1;
+	std::string file;
+	int fileNum = 1;
 
-    if (!node)  return;
+	if (!node)
+		return;
 
-    if (node->first_attribute("filename"))
-        file = node->first_attribute("filename")->value();
+	if (node->first_attribute("filename"))
+		file = node->first_attribute("filename")->value();
 
-    for ( ; ; )
-    {
-        std::ostringstream fileName;
-        fileName << file << std::setfill ('0') << std::setw (3) << fileNum;
+	for (;;)
+	{
+		std::ostringstream fileName;
+		fileName << file << std::setfill ('0') << std::setw (3) << fileNum;
 
-        gr_surface surface;
-        if (pZip)
-        {
-            if (ExtractResource(pZip, "images", fileName.str(), ".png", TMP_RESOURCE_NAME) != 0)
-                break;
-    
-            if (res_create_surface(TMP_RESOURCE_NAME, &surface))
-                break;
+		gr_surface surface;
+		if (pZip)
+		{
+			if (ExtractResource(pZip, "images", fileName.str(), ".png", TMP_RESOURCE_NAME) != 0)
+				break;
+	
+			if (res_create_surface(TMP_RESOURCE_NAME, &surface))
+				break;
 
-            unlink(TMP_RESOURCE_NAME);
-        }
-        else
-        {
-            if (res_create_surface(fileName.str().c_str(), &surface))
-                break;
-        }
-        mSurfaces.push_back(surface);
-        fileNum++;
-    }
+			unlink(TMP_RESOURCE_NAME);
+		}
+		else
+		{
+			if (res_create_surface(fileName.str().c_str(), &surface))
+				break;
+		}
+		mSurfaces.push_back(surface);
+		fileNum++;
+	}
 }
 
 AnimationResource::~AnimationResource()
 {
-    std::vector<gr_surface>::iterator it;
+	std::vector<gr_surface>::iterator it;
 
-    for (it = mSurfaces.begin(); it != mSurfaces.end(); ++it)
-    {
-        res_free_surface(*it);
-    }
-    mSurfaces.clear();
+	for (it = mSurfaces.begin(); it != mSurfaces.end(); ++it)
+		res_free_surface(*it);
+
+	mSurfaces.clear();
 }
 
 Resource* ResourceManager::FindResource(std::string name)
 {
-    std::vector<Resource*>::iterator iter;
+	std::vector<Resource*>::iterator iter;
 
-    for (iter = mResources.begin(); iter != mResources.end(); iter++)
-    {
-        if (name == (*iter)->GetName())
-            return (*iter);
-    }
-    return NULL;
+	for (iter = mResources.begin(); iter != mResources.end(); iter++)
+	{
+		if (name == (*iter)->GetName())
+			return (*iter);
+	}
+	return NULL;
 }
 
 ResourceManager::ResourceManager(xml_node<>* resList, ZipArchive* pZip)
 {
-    xml_node<>* child;
+	xml_node<>* child;
 
-    if (!resList)       return;
+	if (!resList)
+		return;
 
-    child = resList->first_node("resource");
-    while (child != NULL)
-    {
-        xml_attribute<>* attr = child->first_attribute("type");
-        if (!attr)
-            break;
+	child = resList->first_node("resource");
+	while (child != NULL)
+	{
+		xml_attribute<>* attr = child->first_attribute("type");
+		if (!attr)
+			break;
 
 		std::string type = attr->value();
 
-        if (type == "font")
-        {
-            FontResource* res = new FontResource(child, pZip);
-            if (res == NULL || res->GetResource() == NULL)
-            {
-                xml_attribute<>* attr_name = child->first_attribute("name");
+		if (type == "font")
+		{
+			FontResource* res = new FontResource(child, pZip);
+			if (res == NULL || res->GetResource() == NULL)
+			{
+				xml_attribute<>* attr_name = child->first_attribute("name");
 
 				if (!attr_name) {
 					std::string res_name = attr_name->value();
@@ -210,39 +210,19 @@
 				} else
 					LOGERR("Resource type (%s) failed to load\n", type.c_str());
 
-                delete res;
-            }
-            else
-            {
-                mResources.push_back((Resource*) res);
-            }
-        }
-        else if (type == "image")
-        {
-			ImageResource* res = new ImageResource(child, pZip);
-            if (res == NULL || res->GetResource() == NULL)
-            {
-                xml_attribute<>* attr_name = child->first_attribute("name");
-
-				if (!attr_name) {
-					std::string res_name = attr_name->value();
-					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
-				} else
-					LOGERR("Resource type (%s) failed to load\n", type.c_str());
-
-                delete res;
-            }
-            else
-            {
+				delete res;
+			}
+			else
+			{
 				mResources.push_back((Resource*) res);
-            }
-        }
-        else if (type == "animation")
-        {
-            AnimationResource* res = new AnimationResource(child, pZip);
-            if (res == NULL || res->GetResource() == NULL)
-            {
-                xml_attribute<>* attr_name = child->first_attribute("name");
+			}
+		}
+		else if (type == "image")
+		{
+			ImageResource* res = new ImageResource(child, pZip);
+			if (res == NULL || res->GetResource() == NULL)
+			{
+				xml_attribute<>* attr_name = child->first_attribute("name");
 
 				if (!attr_name) {
 					std::string res_name = attr_name->value();
@@ -250,30 +230,48 @@
 				} else
 					LOGERR("Resource type (%s) failed to load\n", type.c_str());
 
-                delete res;
-            }
-            else
-            {
-                mResources.push_back((Resource*) res);
-            }
-        }
-        else
-        {
-            LOGERR("Resource type (%s) not supported.\n", type.c_str());
-        }
+				delete res;
+			}
+			else
+			{
+				mResources.push_back((Resource*) res);
+			}
+		}
+		else if (type == "animation")
+		{
+			AnimationResource* res = new AnimationResource(child, pZip);
+			if (res == NULL || res->GetResource() == NULL)
+			{
+				xml_attribute<>* attr_name = child->first_attribute("name");
 
-        child = child->next_sibling("resource");
-    }
+				if (!attr_name) {
+					std::string res_name = attr_name->value();
+					LOGERR("Resource (%s)-(%s) failed to load\n", type.c_str(), res_name.c_str());
+				} else
+					LOGERR("Resource type (%s) failed to load\n", type.c_str());
+
+				delete res;
+			}
+			else
+			{
+				mResources.push_back((Resource*) res);
+			}
+		}
+		else
+		{
+			LOGERR("Resource type (%s) not supported.\n", type.c_str());
+		}
+
+		child = child->next_sibling("resource");
+	}
 }
 
 ResourceManager::~ResourceManager()
 {
-    std::vector<Resource*>::iterator iter;
+	std::vector<Resource*>::iterator iter;
 
-    for (iter = mResources.begin(); iter != mResources.end(); iter++)
-    {
-        delete *iter;
-    }
-    mResources.clear();
+	for (iter = mResources.begin(); iter != mResources.end(); iter++)
+		delete *iter;
+
+	mResources.clear();
 }
-
diff --git a/gui/resources.hpp b/gui/resources.hpp
index 6cb5da2..4e05e41 100644
--- a/gui/resources.hpp
+++ b/gui/resources.hpp
@@ -7,24 +7,24 @@
 class Resource
 {
 public:
-    Resource(xml_node<>* node, ZipArchive* pZip);
-    virtual ~Resource()         {}
+	Resource(xml_node<>* node, ZipArchive* pZip);
+	virtual ~Resource() {}
 
 public:
-    virtual void* GetResource(void) = 0;
-    std::string GetName(void) { return mName; }
+	virtual void* GetResource(void) = 0;
+	std::string GetName(void) { return mName; }
 
 private:
-    std::string mName;
+	std::string mName;
 
 protected:
-    static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
+	static int ExtractResource(ZipArchive* pZip, std::string folderName, std::string fileName, std::string fileExtn, std::string destFile);
 };
 
 typedef enum {
-    TOUCH_START = 0, 
-    TOUCH_DRAG = 1,
-    TOUCH_RELEASE = 2,
+	TOUCH_START = 0, 
+	TOUCH_DRAG = 1,
+	TOUCH_RELEASE = 2,
 	TOUCH_HOLD = 3,
 	TOUCH_REPEAT = 4
 } TOUCH_STATE;
@@ -32,56 +32,55 @@
 class FontResource : public Resource
 {
 public:
-    FontResource(xml_node<>* node, ZipArchive* pZip);
-    virtual ~FontResource();
+	FontResource(xml_node<>* node, ZipArchive* pZip);
+	virtual ~FontResource();
 
 public:
-    virtual void* GetResource(void) { return mFont; }
+	virtual void* GetResource(void) { return mFont; }
 
 protected:
-    void* mFont;
+	void* mFont;
 };
 
 class ImageResource : public Resource
 {
 public:
-    ImageResource(xml_node<>* node, ZipArchive* pZip);
-    virtual ~ImageResource();
+	ImageResource(xml_node<>* node, ZipArchive* pZip);
+	virtual ~ImageResource();
 
 public:
-    virtual void* GetResource(void) { return mSurface; }
+	virtual void* GetResource(void) { return mSurface; }
 
 protected:
-    gr_surface mSurface;
+	gr_surface mSurface;
 };
 
 class AnimationResource : public Resource
 {
 public:
-    AnimationResource(xml_node<>* node, ZipArchive* pZip);
-    virtual ~AnimationResource();
+	AnimationResource(xml_node<>* node, ZipArchive* pZip);
+	virtual ~AnimationResource();
 
 public:
-    virtual void* GetResource(void)         { return mSurfaces.at(0); }
-    virtual void* GetResource(int entry)    { return mSurfaces.at(entry); }
-    virtual int GetResourceCount(void)      { return mSurfaces.size(); }
+	virtual void* GetResource(void) { return mSurfaces.at(0); }
+	virtual void* GetResource(int entry) { return mSurfaces.at(entry); }
+	virtual int GetResourceCount(void) { return mSurfaces.size(); }
 
 protected:
-    std::vector<gr_surface> mSurfaces;
+	std::vector<gr_surface> mSurfaces;
 };
 
 class ResourceManager
 {
 public:
-    ResourceManager(xml_node<>* resList, ZipArchive* pZip);
-    virtual ~ResourceManager();
+	ResourceManager(xml_node<>* resList, ZipArchive* pZip);
+	virtual ~ResourceManager();
 
 public:
-    Resource* FindResource(std::string name);
+	Resource* FindResource(std::string name);
 
 private:
-    std::vector<Resource*> mResources;
+	std::vector<Resource*> mResources;
 };
 
 #endif  // _RESOURCE_HEADER
-
diff --git a/gui/slider.cpp b/gui/slider.cpp
index 4542d60..b46d156 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -28,143 +28,143 @@
 
 GUISlider::GUISlider(xml_node<>* node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    sAction = NULL;
-    sSlider = NULL;
-    sSliderUsed = NULL;
-    sTouch = NULL;
-    sTouchW = 20;
+	sAction = NULL;
+	sSlider = NULL;
+	sSliderUsed = NULL;
+	sTouch = NULL;
+	sTouchW = 20;
 
-    if (!node)
-    {
-        LOGERR("GUISlider created without XML node\n");
-        return;
-    }
+	if (!node)
+	{
+		LOGERR("GUISlider created without XML node\n");
+		return;
+	}
 
-    child = node->first_node("resource");
-    if (child)
-    {
-        attr = child->first_attribute("base");
-        if (attr)
-            sSlider = PageManager::FindResource(attr->value());
+	child = node->first_node("resource");
+	if (child)
+	{
+		attr = child->first_attribute("base");
+		if (attr)
+			sSlider = PageManager::FindResource(attr->value());
 
-        attr = child->first_attribute("used");
-        if (attr)
-            sSliderUsed = PageManager::FindResource(attr->value());
+		attr = child->first_attribute("used");
+		if (attr)
+			sSliderUsed = PageManager::FindResource(attr->value());
 
-        attr = child->first_attribute("touch");
-        if (attr)
-            sTouch = PageManager::FindResource(attr->value());
-    }
+		attr = child->first_attribute("touch");
+		if (attr)
+			sTouch = PageManager::FindResource(attr->value());
+	}
 
-    // Load the placement
+	// Load the placement
 	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY);
 
-    if (sSlider && sSlider->GetResource())
-    {
+	if (sSlider && sSlider->GetResource())
+	{
 		mRenderW = gr_get_width(sSlider->GetResource());
-        mRenderH = gr_get_height(sSlider->GetResource());
-    }
-    if (sTouch && sTouch->GetResource())
-    {
-        sTouchW = gr_get_width(sTouch->GetResource());  // Width of the "touch image" that follows the touch (arrow)
-        sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow)
-    }
+		mRenderH = gr_get_height(sSlider->GetResource());
+	}
+	if (sTouch && sTouch->GetResource())
+	{
+		sTouchW = gr_get_width(sTouch->GetResource());  // Width of the "touch image" that follows the touch (arrow)
+		sTouchH = gr_get_height(sTouch->GetResource()); // Height of the "touch image" that follows the touch (arrow)
+	}
 
-    //LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
+	//LOGINFO("mRenderW: %i mTouchW: %i\n", mRenderW, mTouchW);
 	mActionX = mRenderX;
-    mActionY = mRenderY;
-    mActionW = mRenderW;
-    mActionH = mRenderH;
+	mActionY = mRenderY;
+	mActionW = mRenderW;
+	mActionH = mRenderH;
 
-    sAction = new GUIAction(node);
+	sAction = new GUIAction(node);
 
-    sCurTouchX = mRenderX;
-    sUpdate = 1;
-
-    return;
+	sCurTouchX = mRenderX;
+	sUpdate = 1;
 }
 
 GUISlider::~GUISlider()
 {
-    delete sAction;
+	delete sAction;
 }
 
 int GUISlider::Render(void)
 {
-    if (!sSlider || !sSlider->GetResource())       return -1;
+	if (!sSlider || !sSlider->GetResource())
+		return -1;
 
-    // Draw the slider
-    gr_blit(sSlider->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
+	// Draw the slider
+	gr_blit(sSlider->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
 
-    // Draw the used
-    if (sSliderUsed && sSliderUsed->GetResource() && sCurTouchX > mRenderX)
-    {
-        gr_blit(sSliderUsed->GetResource(), 0, 0, sCurTouchX - mRenderX, mRenderH, mRenderX, mRenderY);
-    }
+	// Draw the used
+	if (sSliderUsed && sSliderUsed->GetResource() && sCurTouchX > mRenderX)
+		gr_blit(sSliderUsed->GetResource(), 0, 0, sCurTouchX - mRenderX, mRenderH, mRenderX, mRenderY);
 
-    // Draw the touch icon
-    if (sTouch && sTouch->GetResource())
-    {
-        gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2)));
-    }
+	// Draw the touch icon
+	if (sTouch && sTouch->GetResource())
+		gr_blit(sTouch->GetResource(), 0, 0, sTouchW, sTouchH, sCurTouchX, (mRenderY + ((mRenderH - sTouchH) / 2)));
 
-    sUpdate = 0;
-    return 0;
+	sUpdate = 0;
+	return 0;
 }
 
 int GUISlider::Update(void)
 {
-    if (sUpdate)    return 2;
-    return 0;
+	if (sUpdate)
+		return 2;
+	return 0;
 }
 
 int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-    static bool dragging = false;
+	static bool dragging = false;
 
 	switch (state)
-    {
-    case TOUCH_START:
-        if (x >= mRenderX && x <= mRenderX + sTouchW && 
-            y >= mRenderY && y <= mRenderY + mRenderH)
-        {
-            sCurTouchX = x - (sTouchW / 2);
-            if (sCurTouchX < mRenderX)  sCurTouchX = mRenderX;
-            dragging = true;
-        }
-        break;
+	{
+	case TOUCH_START:
+		if (x >= mRenderX && x <= mRenderX + sTouchW && 
+			y >= mRenderY && y <= mRenderY + mRenderH)
+		{
+			sCurTouchX = x - (sTouchW / 2);
+			if (sCurTouchX < mRenderX)
+				sCurTouchX = mRenderX;
+			dragging = true;
+		}
+		break;
 
-    case TOUCH_DRAG:
-        if (!dragging)  return 0;
-        if (y < mRenderY - sTouchH || y > mRenderY + (sTouchH * 2))
-        {
-            sCurTouchX = mRenderX;
-            dragging = false;
-            sUpdate = 1;
-            break;
-        }
-        sCurTouchX = x - (sTouchW / 2);
-        if (sCurTouchX < mRenderX)                          sCurTouchX = mRenderX;
-        if (sCurTouchX > mRenderX + mRenderW - sTouchW)     sCurTouchX = mRenderX + mRenderW - sTouchW;
-        sUpdate = 1;
-        break;
+	case TOUCH_DRAG:
+		if (!dragging)
+			return 0;
+		if (y < mRenderY - sTouchH || y > mRenderY + (sTouchH * 2))
+		{
+			sCurTouchX = mRenderX;
+			dragging = false;
+			sUpdate = 1;
+			break;
+		}
+		sCurTouchX = x - (sTouchW / 2);
+		if (sCurTouchX < mRenderX)
+			sCurTouchX = mRenderX;
+		if (sCurTouchX > mRenderX + mRenderW - sTouchW)
+			sCurTouchX = mRenderX + mRenderW - sTouchW;
+		sUpdate = 1;
+		break;
 
-    case TOUCH_RELEASE:
-        if (!dragging)  return 0;
-        if (sCurTouchX >= mRenderX + mRenderW - sTouchW)
-        {
-            sAction->doActions();
-        }
-        sCurTouchX = mRenderX;
-        dragging = false;
-        sUpdate = 1;
+	case TOUCH_RELEASE:
+		if (!dragging)
+			return 0;
+
+		if (sCurTouchX >= mRenderX + mRenderW - sTouchW)
+			sAction->doActions();
+
+		sCurTouchX = mRenderX;
+		dragging = false;
+		sUpdate = 1;
 	case TOUCH_REPEAT:
 	case TOUCH_HOLD:
-        break;
-    }
-    return 0;
+		break;
+	}
+	return 0;
 }
-
diff --git a/gui/text.cpp b/gui/text.cpp
index 46a6622..7eb6c18 100644
--- a/gui/text.cpp
+++ b/gui/text.cpp
@@ -26,116 +26,119 @@
 #include "objects.hpp"
 
 GUIText::GUIText(xml_node<>* node)
-    : Conditional(node)
+	: Conditional(node)
 {
-    xml_attribute<>* attr;
-    xml_node<>* child;
+	xml_attribute<>* attr;
+	xml_node<>* child;
 
-    mFont = NULL;
-    mIsStatic = 1;
-    mVarChanged = 0;
-    mFontHeight = 0;
+	mFont = NULL;
+	mIsStatic = 1;
+	mVarChanged = 0;
+	mFontHeight = 0;
 	maxWidth = 0;
 	charSkip = 0;
 	isHighlighted = false;
 	hasHighlightColor = false;
 
-    if (!node)      return;
+	if (!node)
+		return;
 
-    // Initialize color to solid black
-    memset(&mColor, 0, sizeof(COLOR));
-    mColor.alpha = 255;
+	// Initialize color to solid black
+	memset(&mColor, 0, sizeof(COLOR));
+	mColor.alpha = 255;
 	memset(&mHighlightColor, 0, sizeof(COLOR));
-    mHighlightColor.alpha = 255;
+	mHighlightColor.alpha = 255;
 
-    attr = node->first_attribute("color");
-    if (attr)
-    {
-        std::string color = attr->value();
-        ConvertStrToColor(color, &mColor);
-    }
+	attr = node->first_attribute("color");
+	if (attr)
+	{
+		std::string color = attr->value();
+		ConvertStrToColor(color, &mColor);
+	}
 	attr = node->first_attribute("highlightcolor");
-    if (attr)
-    {
-        std::string color = attr->value();
+	if (attr)
+	{
+		std::string color = attr->value();
 		ConvertStrToColor(color, &mHighlightColor);
 		hasHighlightColor = true;
-    }
+	}
 
-    // Load the font, and possibly override the color
-    child = node->first_node("font");
-    if (child)
-    {
-        attr = child->first_attribute("resource");
-        if (attr)
-            mFont = PageManager::FindResource(attr->value());
+	// Load the font, and possibly override the color
+	child = node->first_node("font");
+	if (child)
+	{
+		attr = child->first_attribute("resource");
+		if (attr)
+			mFont = PageManager::FindResource(attr->value());
 
-        attr = child->first_attribute("color");
-        if (attr)
-        {
-            std::string color = attr->value();
-            ConvertStrToColor(color, &mColor);
-        }
+		attr = child->first_attribute("color");
+		if (attr)
+		{
+			std::string color = attr->value();
+			ConvertStrToColor(color, &mColor);
+		}
 
 		attr = child->first_attribute("highlightcolor");
-        if (attr)
-        {
-            std::string color = attr->value();
+		if (attr)
+		{
+			std::string color = attr->value();
 			ConvertStrToColor(color, &mHighlightColor);
 			hasHighlightColor = true;
-        }
-    }
+		}
+	}
 
-    // Load the placement
-    LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &mPlacement);
+	// Load the placement
+	LoadPlacement(node->first_node("placement"), &mRenderX, &mRenderY, &mRenderW, &mRenderH, &mPlacement);
 
-    child = node->first_node("text");
-    if (child)  mText = child->value();
+	child = node->first_node("text");
+	if (child)  mText = child->value();
 
-    // Simple way to check for static state
-    mLastValue = parseText();
-    if (mLastValue != mText)   mIsStatic = 0;
+	// Simple way to check for static state
+	mLastValue = parseText();
+	if (mLastValue != mText)   mIsStatic = 0;
 
-    gr_getFontDetails(mFont ? mFont->GetResource() : NULL, (unsigned*) &mFontHeight, NULL);
-    return;
+	gr_getFontDetails(mFont ? mFont->GetResource() : NULL, (unsigned*) &mFontHeight, NULL);
+	return;
 }
 
 int GUIText::Render(void)
 {
-    if (!isConditionTrue())     return 0;
+	if (!isConditionTrue())
+		return 0;
 
-    void* fontResource = NULL;
+	void* fontResource = NULL;
 	string displayValue;
 
-    if (mFont)  fontResource = mFont->GetResource();
+	if (mFont)
+		fontResource = mFont->GetResource();
 
-    mLastValue = parseText();
+	mLastValue = parseText();
 	displayValue = mLastValue;
 
 	if (charSkip)
 		displayValue.erase(0, charSkip);
 
-    mVarChanged = 0;
+	mVarChanged = 0;
 
-    int x = mRenderX, y = mRenderY;
-    int width = gr_measureEx(displayValue.c_str(), fontResource);
+	int x = mRenderX, y = mRenderY;
+	int width = gr_measureEx(displayValue.c_str(), fontResource);
 
-    if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
-    {
-        if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY)
-            x -= (width / 2);
-        else
-            x -= width;
-    }
-    if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
-    {
-        if (mPlacement == CENTER)
-            y -= (mFontHeight / 2);
-        else if (mPlacement == BOTTOM_LEFT || mPlacement == BOTTOM_RIGHT)
-            y -= mFontHeight;
-    }
+	if (mPlacement != TOP_LEFT && mPlacement != BOTTOM_LEFT)
+	{
+		if (mPlacement == CENTER || mPlacement == CENTER_X_ONLY)
+			x -= (width / 2);
+		else
+			x -= width;
+	}
+	if (mPlacement != TOP_LEFT && mPlacement != TOP_RIGHT)
+	{
+		if (mPlacement == CENTER)
+			y -= (mFontHeight / 2);
+		else if (mPlacement == BOTTOM_LEFT || mPlacement == BOTTOM_RIGHT)
+			y -= mFontHeight;
+	}
 
-    if (hasHighlightColor && isHighlighted)
+	if (hasHighlightColor && isHighlighted)
 		gr_color(mHighlightColor.red, mHighlightColor.green, mHighlightColor.blue, mHighlightColor.alpha);
 	else
 		gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
@@ -144,82 +147,85 @@
 		gr_textExW(x, y, displayValue.c_str(), fontResource, maxWidth + x);
 	else
 		gr_textEx(x, y, displayValue.c_str(), fontResource);
-    return 0;
+	return 0;
 }
 
 int GUIText::Update(void)
 {
-    if (!isConditionTrue())     return 0;
+	if (!isConditionTrue())
+		return 0;
 
-    static int updateCounter = 3;
+	static int updateCounter = 3;
 
-    // This hack just makes sure we update at least once a minute for things like clock and battery
-    if (updateCounter)  updateCounter--;
-    else
-    {
-        mVarChanged = 1;
-        updateCounter = 3;
-    }
+	// This hack just makes sure we update at least once a minute for things like clock and battery
+	if (updateCounter)  updateCounter--;
+	else
+	{
+		mVarChanged = 1;
+		updateCounter = 3;
+	}
 
-    if (mIsStatic || !mVarChanged)      return 0;
+	if (mIsStatic || !mVarChanged)
+		return 0;
 
-    std::string newValue = parseText();
-    if (mLastValue == newValue)
+	std::string newValue = parseText();
+	if (mLastValue == newValue)
 		return 0;
 	else
 		mLastValue = newValue;
-    return 2;
+	return 2;
 }
 
 int GUIText::GetCurrentBounds(int& w, int& h)
 {
-    void* fontResource = NULL;
+	void* fontResource = NULL;
 
-    if (mFont)  fontResource = mFont->GetResource();
+	if (mFont)
+		fontResource = mFont->GetResource();
 
-    h = mFontHeight;
+	h = mFontHeight;
 	mLastValue = parseText();
-    w = gr_measureEx(mLastValue.c_str(), fontResource);
-    return 0;
+	w = gr_measureEx(mLastValue.c_str(), fontResource);
+	return 0;
 }
 
 std::string GUIText::parseText(void)
 {
-    static int counter = 0;
-    std::string str = mText;
-    size_t pos = 0;
-    size_t next = 0, end = 0;
+	static int counter = 0;
+	std::string str = mText;
+	size_t pos = 0;
+	size_t next = 0, end = 0;
 
-    while (1)
-    {
-        next = str.find('%', pos);
-        if (next == std::string::npos)      return str;
-        end = str.find('%', next + 1);
-        if (end == std::string::npos)       return str;
+	while (1)
+	{
+		next = str.find('%', pos);
+		if (next == std::string::npos) return str;
+		end = str.find('%', next + 1);
+		if (end == std::string::npos) return str;
 
-        // We have a block of data
-        std::string var = str.substr(next + 1, (end - next) - 1);
-        str.erase(next, (end - next) + 1);
+		// We have a block of data
+		std::string var = str.substr(next + 1, (end - next) - 1);
+		str.erase(next, (end - next) + 1);
 
-        if (next + 1 == end)
-        {
-            str.insert(next, 1, '%');
-        }
-        else
-        {
-            std::string value;
-            if (DataManager::GetValue(var, value) == 0)
-                str.insert(next, value);
-        }
+		if (next + 1 == end)
+		{
+			str.insert(next, 1, '%');
+		}
+		else
+		{
+			std::string value;
+			if (DataManager::GetValue(var, value) == 0)
+				str.insert(next, value);
+		}
 
-        pos = next + 1;
-    }
+		pos = next + 1;
+	}
 }
 
 int GUIText::NotifyVarChange(std::string varName, std::string value)
 {
-    mVarChanged = 1;
-    return 0;
+	mVarChanged = 1;
+	return 0;
 }
 
 int GUIText::SetMaxWidth(unsigned width)
diff --git a/partition.cpp b/partition.cpp
index dc71bb9..e02def0 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -1062,7 +1062,7 @@
 
 	gui_print("Wiping %s\n", Backup_Display_Name.c_str());
 	TWFunc::removeDir(Mount_Point + "/.android_secure/", true);
-    return true;
+	return true;
 }
 
 bool TWPartition::Backup(string backup_folder) {
@@ -1361,31 +1361,31 @@
 
 	gui_print("MTD Formatting \"%s\"\n", MTD_Name.c_str());
 
-    mtd_scan_partitions();
-    const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str());
-    if (mtd == NULL) {
-        LOGERR("No mtd partition named '%s'", MTD_Name.c_str());
-        return false;
-    }
+	mtd_scan_partitions();
+	const MtdPartition* mtd = mtd_find_partition_by_name(MTD_Name.c_str());
+	if (mtd == NULL) {
+		LOGERR("No mtd partition named '%s'", MTD_Name.c_str());
+		return false;
+	}
 
-    MtdWriteContext* ctx = mtd_write_partition(mtd);
-    if (ctx == NULL) {
-        LOGERR("Can't write '%s', failed to format.", MTD_Name.c_str());
-        return false;
-    }
-    if (mtd_erase_blocks(ctx, -1) == -1) {
-        mtd_write_close(ctx);
-        LOGERR("Failed to format '%s'", MTD_Name.c_str());
-        return false;
-    }
-    if (mtd_write_close(ctx) != 0) {
-        LOGERR("Failed to close '%s'", MTD_Name.c_str());
-        return false;
-    }
+	MtdWriteContext* ctx = mtd_write_partition(mtd);
+	if (ctx == NULL) {
+		LOGERR("Can't write '%s', failed to format.", MTD_Name.c_str());
+		return false;
+	}
+	if (mtd_erase_blocks(ctx, -1) == -1) {
+		mtd_write_close(ctx);
+		LOGERR("Failed to format '%s'", MTD_Name.c_str());
+		return false;
+	}
+	if (mtd_write_close(ctx) != 0) {
+		LOGERR("Failed to close '%s'", MTD_Name.c_str());
+		return false;
+	}
 	Current_File_System = "yaffs2";
 	Recreate_AndSec_Folder();
 	gui_print("Done.\n");
-    return true;
+	return true;
 }
 
 bool TWPartition::Wipe_RMRF() {
@@ -1415,7 +1415,7 @@
 			if (strcmp(de->d_name, ".") == 0 || strcmp(de->d_name, "..") == 0)   continue;
 			// The media folder is the "internal sdcard"
 			// The .layout_version file is responsible for determining whether 4.2 decides up upgrade
-			//    the media folder for multi-user.
+			// the media folder for multi-user.
 			if (strcmp(de->d_name, "media") == 0 || strcmp(de->d_name, ".layout_version") == 0)   continue;
 			
 			dir = "/data/";
@@ -1560,7 +1560,7 @@
 	} else {
 		gui_print("Wiping %s...\n", Display_Name.c_str());
 		if (!Wipe(Restore_File_System))
-		    return false;
+			return false;
 	}
 	TWFunc::GUI_Operation_Text(TW_RESTORE_TEXT, Backup_Display_Name, "Restoring");
 	gui_print("Restoring %s...\n", Backup_Display_Name.c_str());
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 71e5e34..77cf37e 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -1104,14 +1104,14 @@
 		}
 	}
 	TWPartition* sdext = Find_Partition_By_Path("/sd-ext");
-	if (sdext != NULL) {
-		if (sdext->Is_Present && sdext->Mount(false)) {
-			if (stat("/sd-ext/dalvik-cache", &st) == 0) {
-				TWFunc::removeDir("/sd-ext/dalvik-cache", false);
-        	    		gui_print("Cleaned: /sd-ext/dalvik-cache...\n");
-			}
+	if (sdext && sdext->Is_Present && sdext->Mount(false))
+	{
+		if (stat("/sd-ext/dalvik-cache", &st) == 0)
+		{
+			TWFunc::removeDir("/sd-ext/dalvik-cache", false);
+	   	    gui_print("Cleaned: /sd-ext/dalvik-cache...\n");
 		}
-        }
+	}
 	gui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
 	return true;
 }
@@ -1893,4 +1893,4 @@
 		}
 	}
 	fclose(fp);
-}
\ No newline at end of file
+}
diff --git a/twbootloader.cpp b/twbootloader.cpp
index 826ceca..d0e49e0 100644
--- a/twbootloader.cpp
+++ b/twbootloader.cpp
@@ -33,33 +33,35 @@
 static int set_bootloader_message_block(const struct bootloader_message *in, const TWPartition* Partition);
 
 int get_bootloader_message(struct bootloader_message *out) {
-    TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
-    if (Part == NULL) {
-      //LOGE("Cannot load volume /misc!\n");
-      return -1;
-    }
-    if (Part->Current_File_System == "mtd") {
-        return get_bootloader_message_mtd(out, Part);
-    } else if (Part->Current_File_System == "emmc") {
-        return get_bootloader_message_block(out, Part);
-    }
-    LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
-    return -1;
+	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
+	if (Part == NULL) {
+	  //LOGE("Cannot load volume /misc!\n");
+	  return -1;
+	}
+
+	if (Part->Current_File_System == "mtd")
+		return get_bootloader_message_mtd(out, Part);
+	else if (Part->Current_File_System == "emmc")
+		return get_bootloader_message_block(out, Part);
+
+	LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
+	return -1;
 }
 
 int set_bootloader_message(const struct bootloader_message *in) {
-    TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
-    if (Part == NULL) {
-      //LOGE("Cannot load volume /misc!\n");
-      return -1;
-    }
-    if (Part->Current_File_System == "mtd") {
-        return set_bootloader_message_mtd(in, Part);
-    } else if (Part->Current_File_System == "emmc") {
-        return set_bootloader_message_block(in, Part);
-    }
-    LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
-    return -1;
+	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
+	if (Part == NULL) {
+	  //LOGE("Cannot load volume /misc!\n");
+	  return -1;
+	}
+
+	if (Part->Current_File_System == "mtd")
+		return set_bootloader_message_mtd(in, Part);
+	else if (Part->Current_File_System == "emmc")
+		return set_bootloader_message_block(in, Part);
+
+	LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
+	return -1;
 }
 
 // ------------------------------
@@ -71,134 +73,141 @@
 
 static int get_bootloader_message_mtd(struct bootloader_message *out,
                                       const TWPartition* Partition) {
-    size_t write_size;
-    mtd_scan_partitions();
-    const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
-    if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
-        LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
-        return -1;
-    }
+	size_t write_size;
+	mtd_scan_partitions();
+	const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
+	if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
+		LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
+		return -1;
+	}
 
-    MtdReadContext *read = mtd_read_partition(part);
-    if (read == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdReadContext *read = mtd_read_partition(part);
+	if (read == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    const ssize_t size = write_size * MISC_PAGES;
-    char data[size];
-    ssize_t r = mtd_read_data(read, data, size);
-    if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-    mtd_read_close(read);
-    if (r != size) return -1;
+	const ssize_t size = write_size * MISC_PAGES;
+	char data[size];
+	ssize_t r = mtd_read_data(read, data, size);
+	if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+	mtd_read_close(read);
+	if (r != size) return -1;
 
-    memcpy(out, &data[write_size * MISC_COMMAND_PAGE], sizeof(*out));
-    return 0;
+	memcpy(out, &data[write_size * MISC_COMMAND_PAGE], sizeof(*out));
+	return 0;
 }
 static int set_bootloader_message_mtd(const struct bootloader_message *in,
                                       const TWPartition* Partition) {
-    size_t write_size;
-    mtd_scan_partitions();
-    const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
-    if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
-        LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
-        return -1;
-    }
+	size_t write_size;
+	mtd_scan_partitions();
+	const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
+	if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
+		LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
+		return -1;
+	}
 
-    MtdReadContext *read = mtd_read_partition(part);
-    if (read == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdReadContext *read = mtd_read_partition(part);
+	if (read == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    ssize_t size = write_size * MISC_PAGES;
-    char data[size];
-    ssize_t r = mtd_read_data(read, data, size);
-    if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-    mtd_read_close(read);
-    if (r != size) return -1;
+	ssize_t size = write_size * MISC_PAGES;
+	char data[size];
+	ssize_t r = mtd_read_data(read, data, size);
+	if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+	mtd_read_close(read);
+	if (r != size) return -1;
 
-    memcpy(&data[write_size * MISC_COMMAND_PAGE], in, sizeof(*in));
+	memcpy(&data[write_size * MISC_COMMAND_PAGE], in, sizeof(*in));
 
-    MtdWriteContext *write = mtd_write_partition(part);
-    if (write == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
-    if (mtd_write_data(write, data, size) != size) {
-        LOGE("Can't write %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        mtd_write_close(write);
-        return -1;
-    }
-    if (mtd_write_close(write)) {
-        LOGE("Can't finish %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdWriteContext *write = mtd_write_partition(part);
+	if (write == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
+	if (mtd_write_data(write, data, size) != size) {
+		LOGE("Can't write %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		mtd_write_close(write);
+		return -1;
+	}
+	if (mtd_write_close(write)) {
+		LOGE("Can't finish %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    LOGI("Set boot command \"%s\"\n", in->command[0] != 255 ? in->command : "");
-    return 0;
+	LOGI("Set boot command \"%s\"\n", in->command[0] != 255 ? in->command : "");
+	return 0;
 }
 
-
 // ------------------------------------
 // for misc partitions on block devices
 // ------------------------------------
 
 static void wait_for_device(const char* fn) {
-    int tries = 0;
-    int ret;
-    struct stat buf;
-    do {
-        ++tries;
-        ret = stat(fn, &buf);
-        if (ret) {
-            printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
-            sleep(1);
-        }
-    } while (ret && tries < 10);
-    if (ret) {
-        printf("failed to stat %s\n", fn);
-    }
+	int tries = 0;
+	int ret;
+	struct stat buf;
+
+	do {
+		++tries;
+		ret = stat(fn, &buf);
+		if (ret) {
+			printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
+			sleep(1);
+		}
+	} while (ret && tries < 10);
+
+	if (ret)
+		printf("failed to stat %s\n", fn);
 }
 
 static int get_bootloader_message_block(struct bootloader_message *out,
                                         const TWPartition* Partition) {
-    wait_for_device(Partition->Actual_Block_Device.c_str());
-    FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "rb");
-    if (f == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    struct bootloader_message temp;
-    int count = fread(&temp, sizeof(temp), 1, f);
-    if (count != 1) {
-        LOGE("Failed reading %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    if (fclose(f) != 0) {
-        LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    memcpy(out, &temp, sizeof(temp));
-    return 0;
+	wait_for_device(Partition->Actual_Block_Device.c_str());
+
+	FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "rb");
+	if (f == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	struct bootloader_message temp;
+	int count = fread(&temp, sizeof(temp), 1, f);
+	if (count != 1) {
+		LOGE("Failed reading %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	if (fclose(f) != 0) {
+		LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	memcpy(out, &temp, sizeof(temp));
+	return 0;
 }
 
 static int set_bootloader_message_block(const struct bootloader_message *in,
                                         const TWPartition* Partition) {
-    wait_for_device(Partition->Actual_Block_Device.c_str());
-    FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "wb");
-    if (f == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    int count = fwrite(in, sizeof(*in), 1, f);
-    if (count != 1) {
-        LOGE("Failed writing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    if (fclose(f) != 0) {
-        LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    return 0;
+	wait_for_device(Partition->Actual_Block_Device.c_str());
+
+	FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "wb");
+	if (f == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	int count = fwrite(in, sizeof(*in), 1, f);
+	if (count != 1) {
+		LOGE("Failed writing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	if (fclose(f) != 0) {
+		LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+	return 0;
 }
diff --git a/twinstall.cpp b/twinstall.cpp
index e7d23ec..041c78d 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -87,37 +87,37 @@
 	child_data = fdopen(pipe_fd[0], "r");
 	while (fgets(buffer, sizeof(buffer), child_data) != NULL) {
 		char* command = strtok(buffer, " \n");
-        if (command == NULL) {
-            continue;
-        } else if (strcmp(command, "progress") == 0) {
-            char* fraction_char = strtok(NULL, " \n");
-            char* seconds_char = strtok(NULL, " \n");
+		if (command == NULL) {
+			continue;
+		} else if (strcmp(command, "progress") == 0) {
+			char* fraction_char = strtok(NULL, " \n");
+			char* seconds_char = strtok(NULL, " \n");
 
-            float fraction_float = strtof(fraction_char, NULL);
-            int seconds_float = strtol(seconds_char, NULL, 10);
+			float fraction_float = strtof(fraction_char, NULL);
+			int seconds_float = strtol(seconds_char, NULL, 10);
 
-            if (zip_verify)
+			if (zip_verify)
 				DataManager::ShowProgress(fraction_float * (1 - VERIFICATION_PROGRESS_FRACTION), seconds_float);
 			else
 				DataManager::ShowProgress(fraction_float, seconds_float);
-        } else if (strcmp(command, "set_progress") == 0) {
-            char* fraction_char = strtok(NULL, " \n");
-            float fraction_float = strtof(fraction_char, NULL);
-            DataManager::SetProgress(fraction_float);
-        } else if (strcmp(command, "ui_print") == 0) {
-            char* display_value = strtok(NULL, "\n");
-            if (display_value) {
-                gui_print("%s", display_value);
-            } else {
-                gui_print("\n");
-            }
-        } else if (strcmp(command, "wipe_cache") == 0) {
-            *wipe_cache = 1;
-        } else if (strcmp(command, "clear_display") == 0) {
-            // Do nothing, not supported by TWRP
-        } else {
-            LOGERR("unknown command [%s]\n", command);
-        }
+		} else if (strcmp(command, "set_progress") == 0) {
+			char* fraction_char = strtok(NULL, " \n");
+			float fraction_float = strtof(fraction_char, NULL);
+			DataManager::SetProgress(fraction_float);
+		} else if (strcmp(command, "ui_print") == 0) {
+			char* display_value = strtok(NULL, "\n");
+			if (display_value) {
+				gui_print("%s", display_value);
+			} else {
+				gui_print("\n");
+			}
+		} else if (strcmp(command, "wipe_cache") == 0) {
+			*wipe_cache = 1;
+		} else if (strcmp(command, "clear_display") == 0) {
+			// Do nothing, not supported by TWRP
+		} else {
+			LOGERR("unknown command [%s]\n", command);
+		}
 	}
 	fclose(child_data);
 
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 29c70a5..1d2d632 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -424,15 +424,17 @@
 }
 
 int TWFunc::read_file(string fn, string& results) {
-        ifstream file;
-        file.open(fn.c_str(), ios::in);
-        if (file.is_open()) {
-                file >> results;
-                file.close();
-                return 0;
+	ifstream file;
+	file.open(fn.c_str(), ios::in);
+
+	if (file.is_open()) {
+		file >> results;
+		file.close();
+		return 0;
 	}
-        LOGINFO("Cannot find file %s\n", fn.c_str());
-        return -1;
+
+	LOGINFO("Cannot find file %s\n", fn.c_str());
+	return -1;
 }
 
 int TWFunc::read_file(string fn, vector<string>& results) {
@@ -498,7 +500,7 @@
 	return temp;
 }
 
- int TWFunc::drop_caches(void) {
+int TWFunc::drop_caches(void) {
 	string file = "/proc/sys/vm/drop_caches";
 	string value = "3";
 	if (write_file(file, value) != 0)
@@ -714,7 +716,7 @@
 	string::size_type i = 0;
 	int firstbyte = 0, secondbyte = 0;
 	char header[3];
-        
+
 	ifstream f;
 	f.open(fn.c_str(), ios::in | ios::binary);
 	f.get(header, 3);
@@ -722,13 +724,12 @@
 	firstbyte = header[i] & 0xff;
 	secondbyte = header[++i] & 0xff;
 
-	if (firstbyte == 0x1f && secondbyte == 0x8b) {
+	if (firstbyte == 0x1f && secondbyte == 0x8b)
 		return 1; // Compressed
-	} else if (firstbyte == 0x4f && secondbyte == 0x41) {
+	else if (firstbyte == 0x4f && secondbyte == 0x41)
 		return 2; // Encrypted
-	} else {
+	else
 		return 0; // Unknown
-	}
 
 	return 0;
 }
diff --git a/twrp-functions.hpp b/twrp-functions.hpp
index 9f66621..8531c09 100644
--- a/twrp-functions.hpp
+++ b/twrp-functions.hpp
@@ -8,12 +8,12 @@
 
 typedef enum
 {
-    rb_current = 0,
-    rb_system,
-    rb_recovery,
-    rb_poweroff,
-    rb_bootloader,     // May also be fastboot
-    rb_download,
+	rb_current = 0,
+	rb_system,
+	rb_recovery,
+	rb_poweroff,
+	rb_bootloader,     // May also be fastboot
+	rb_download,
 } RebootCommand;
 
 // Partition class
diff --git a/twrp.cpp b/twrp.cpp
index 04851aa..2c2aed4 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -152,7 +152,7 @@
 		}
 	}
 
-    char twrp_booted[PROPERTY_VALUE_MAX];
+	char twrp_booted[PROPERTY_VALUE_MAX];
 	property_get("ro.twrp.boot", twrp_booted, "0");
 	if (strcmp(twrp_booted, "0") == 0) {
 		property_list(Print_Prop, NULL);
@@ -242,10 +242,10 @@
 		PartitionManager.UnMount_By_Path("/system", false);
 	}
 
-    // Reboot
+	// Reboot
 	TWFunc::Update_Intent_File(Reboot_Value);
-    TWFunc::Update_Log_File();
-    gui_print("Rebooting...\n");
+	TWFunc::Update_Log_File();
+	gui_print("Rebooting...\n");
 	string Reboot_Arg;
 	DataManager::GetValue("tw_reboot_arg", Reboot_Arg);
 	if (Reboot_Arg == "recovery")
@@ -260,9 +260,9 @@
 		TWFunc::tw_reboot(rb_system);
 
 #ifdef ANDROID_RB_RESTART
-    android_reboot(ANDROID_RB_RESTART, 0, 0);
+	android_reboot(ANDROID_RB_RESTART, 0, 0);
 #else
 	reboot(RB_AUTOBOOT);
 #endif
-    return 0;
+	return 0;
 }
diff --git a/twrpDigest.cpp b/twrpDigest.cpp
index 663d085..ce3d87c 100644
--- a/twrpDigest.cpp
+++ b/twrpDigest.cpp
@@ -16,10 +16,12 @@
 	along with TWRP.  If not, see <http://www.gnu.org/licenses/>.
 */
 
-extern "C" {
+extern "C"
+{
 	#include "digest/md5.h"
 	#include "libcrecovery/common.h"
 }
+
 #include <vector>
 #include <string>
 #include <sstream>
diff --git a/twrpDigest.hpp b/twrpDigest.hpp
index 395c0ae..237e580 100644
--- a/twrpDigest.hpp
+++ b/twrpDigest.hpp
@@ -18,18 +18,21 @@
 extern "C" {
 	#include "digest/md5.h"
 }
+
 using namespace std;
 
-class twrpDigest {
-	public:
-                void setfn(string fn);
-                void setdir(string dir);
-		int computeMD5(void);
-		int verify_md5digest(void);
-		int write_md5digest(void);
-	private:
-		int read_md5digest(void);
-		string md5fn;
-		string line;
-		unsigned char md5sum[MD5LENGTH];
+class twrpDigest
+{
+public:
+	void setfn(string fn);
+	void setdir(string dir);
+	int computeMD5(void);
+	int verify_md5digest(void);
+	int write_md5digest(void);
+
+private:
+	int read_md5digest(void);
+	string md5fn;
+	string line;
+	unsigned char md5sum[MD5LENGTH];
 };
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 59d75d0..5964f2f 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -1297,7 +1297,7 @@
 
 unsigned long long twrpTar::uncompressedSize() {
 	int type = 0;
-        unsigned long long total_size = 0;
+	unsigned long long total_size = 0;
 	string Tar, Command, result;
 	vector<string> split;
 
diff --git a/twrpTar.hpp b/twrpTar.hpp
index e270d90..88eedb5 100644
--- a/twrpTar.hpp
+++ b/twrpTar.hpp
@@ -17,7 +17,7 @@
 */
 
 extern "C" {
-        #include "libtar/libtar.h"
+	#include "libtar/libtar.h"
 }
 #include <sys/types.h>
 #include <sys/stat.h>
@@ -41,59 +41,60 @@
 };
 
 class twrpTar {
-	public:
-		twrpTar();
-		virtual ~twrpTar();
-		int createTarFork();
-		int extractTarFork();
-		int splitArchiveFork();
-		void setexcl(string exclude);
-		void setfn(string fn);
-		void setdir(string dir);
-		unsigned long long uncompressedSize();
-		
-	public:
-		int use_encryption;
-		int userdata_encryption;
-		int use_compression;
-		int split_archives;
-		int has_data_media;
-		string backup_name;
+public:
+	twrpTar();
+	virtual ~twrpTar();
+	int createTarFork();
+	int extractTarFork();
+	int splitArchiveFork();
+	void setexcl(string exclude);
+	void setfn(string fn);
+	void setdir(string dir);
+	unsigned long long uncompressedSize();
+	
+public:
+	int use_encryption;
+	int userdata_encryption;
+	int use_compression;
+	int split_archives;
+	int has_data_media;
+	string backup_name;
 
-	private:
-		int extract();
-		int addFilesToExistingTar(vector <string> files, string tarFile);
-		int createTar();
-		int addFile(string fn, bool include_root);
-		int entryExists(string entry);
-		int closeTar();
-		int create();
-		int Split_Archive();
-		int removeEOT(string tarFile);
-		int extractTar();
-		int tarDirs(bool include_root);
-		int Generate_Multiple_Archives(string Path);
-		string Strip_Root_Dir(string Path);
-		int openTar();
-		int Archive_File_Count;
-		int Archive_Current_Type;
-		unsigned long long Archive_Current_Size;
-		TAR *t;
-		int fd;
-		pid_t pigz_pid;
-		pid_t oaes_pid;
+private:
+	int extract();
+	int addFilesToExistingTar(vector <string> files, string tarFile);
+	int createTar();
+	int addFile(string fn, bool include_root);
+	int entryExists(string entry);
+	int closeTar();
+	int create();
+	int Split_Archive();
+	int removeEOT(string tarFile);
+	int extractTar();
+	int tarDirs(bool include_root);
+	int Generate_Multiple_Archives(string Path);
+	string Strip_Root_Dir(string Path);
+	int openTar();
+	int Generate_TarList(string Path, std::vector<TarListStruct> *TarList, unsigned long long *Target_Size, unsigned *thread_id);
+	static void* createList(void *cookie);
+	static void* extractMulti(void *cookie);
+	int tarList(bool include_root, std::vector<TarListStruct> *TarList, unsigned thread_id);
 
-		string tardir;
-		string tarfn;
-		string basefn;
-		string tarexclude;
+	int Archive_File_Count;
+	int Archive_Current_Type;
+	unsigned long long Archive_Current_Size;
+	TAR *t;
+	int fd;
+	pid_t pigz_pid;
+	pid_t oaes_pid;
 
-		vector<string> split;
+	string tardir;
+	string tarfn;
+	string basefn;
+	string tarexclude;
 
-		int Generate_TarList(string Path, std::vector<TarListStruct> *TarList, unsigned long long *Target_Size, unsigned *thread_id);
-		static void* createList(void *cookie);
-		static void* extractMulti(void *cookie);
-		int tarList(bool include_root, std::vector<TarListStruct> *TarList, unsigned thread_id);
-		std::vector<TarListStruct> *ItemList;
-		int thread_id;
+	vector<string> split;
+
+	std::vector<TarListStruct> *ItemList;
+	int thread_id;
 };