Whitespace cleanup

Change-Id: I93c65973679894bb8587da4b38b410d38036b8bd
diff --git a/data.cpp b/data.cpp
index eda2339..65db77a 100644
--- a/data.cpp
+++ b/data.cpp
@@ -253,7 +253,7 @@
 	pthread_mutex_unlock(&m_valuesLock);
 	string current = GetCurrentStoragePath();
 	TWPartition* Part = PartitionManager.Find_Partition_By_Path(current);
-	if(!Part)
+	if (!Part)
 		Part = PartitionManager.Get_Default_Storage_Partition();
 	if (Part && current != Part->Storage_Path && Part->Mount(false)) {
 		LOGINFO("LoadValues setting storage path to '%s'\n", Part->Storage_Path.c_str());
@@ -536,7 +536,7 @@
 	mPersist.SetValue("tw_action_vibrate", "160");
 
 	TWPartition *store = PartitionManager.Get_Default_Storage_Partition();
-	if(store)
+	if (store)
 		mPersist.SetValue("tw_storage_path", store->Storage_Path);
 	else
 		mPersist.SetValue("tw_storage_path", "/");
@@ -753,7 +753,7 @@
 		string maxbrightpath = findbright.insert(findbright.rfind('/') + 1, "max_");
 		if (TWFunc::Path_Exists(maxbrightpath)) {
 			ifstream maxVal(maxbrightpath.c_str());
-			if(maxVal >> maxBrightness) {
+			if (maxVal >> maxBrightness) {
 				LOGINFO("Got max brightness %s from '%s'\n", maxBrightness.c_str(), maxbrightpath.c_str());
 			} else {
 				// Something went wrong, set that to indicate error
@@ -873,38 +873,38 @@
 	}
 	else if (varName == "tw_cpu_temp")
 	{
-	   int tw_no_cpu_temp;
-	   GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
-	   if (tw_no_cpu_temp == 1) return -1;
+		int tw_no_cpu_temp;
+		GetValue("tw_no_cpu_temp", tw_no_cpu_temp);
+		if (tw_no_cpu_temp == 1) return -1;
 
-	   string cpu_temp_file;
-	   static unsigned long convert_temp = 0;
-	   static time_t cpuSecCheck = 0;
-	   int divisor = 0;
-	   struct timeval curTime;
-	   string results;
+		string cpu_temp_file;
+		static unsigned long convert_temp = 0;
+		static time_t cpuSecCheck = 0;
+		int divisor = 0;
+		struct timeval curTime;
+		string results;
 
-	   gettimeofday(&curTime, NULL);
-	   if (curTime.tv_sec > cpuSecCheck)
-	   {
+		gettimeofday(&curTime, NULL);
+		if (curTime.tv_sec > cpuSecCheck)
+		{
 #ifdef TW_CUSTOM_CPU_TEMP_PATH
-		   cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
-		   if (TWFunc::read_file(cpu_temp_file, results) != 0)
-			return -1;
+			cpu_temp_file = EXPAND(TW_CUSTOM_CPU_TEMP_PATH);
+			if (TWFunc::read_file(cpu_temp_file, results) != 0)
+				return -1;
 #else
-		   cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
-		   if (TWFunc::read_file(cpu_temp_file, results) != 0)
-			return -1;
+			cpu_temp_file = "/sys/class/thermal/thermal_zone0/temp";
+			if (TWFunc::read_file(cpu_temp_file, results) != 0)
+				return -1;
 #endif
-		   convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
-		   if (convert_temp <= 0)
-			convert_temp = strtoul(results.c_str(), NULL, 0);
-		   if (convert_temp >= 150)
-			convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
-		   cpuSecCheck = curTime.tv_sec + 5;
-	   }
-	   value = TWFunc::to_string(convert_temp);
-	   return 0;
+			convert_temp = strtoul(results.c_str(), NULL, 0) / 1000;
+			if (convert_temp <= 0)
+				convert_temp = strtoul(results.c_str(), NULL, 0);
+			if (convert_temp >= 150)
+				convert_temp = strtoul(results.c_str(), NULL, 0) / 10;
+			cpuSecCheck = curTime.tv_sec + 5;
+		}
+		value = TWFunc::to_string(convert_temp);
+		return 0;
 	}
 	else if (varName == "tw_battery")
 	{
@@ -924,7 +924,7 @@
 #else
 			FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
 #endif
-			if (cap){
+			if (cap) {
 				fgets(cap_s, 4, cap);
 				fclose(cap);
 				lastVal = atoi(cap_s);
diff --git a/exclude.cpp b/exclude.cpp
index 789c246..8ce138a 100644
--- a/exclude.cpp
+++ b/exclude.cpp
@@ -100,8 +100,8 @@
 bool TWExclude::check_skip_dirs(const string& path) {
 	string normalized = TWFunc::Remove_Trailing_Slashes(path);
 	size_t slashIdx = normalized.find_last_of('/');
-	if(slashIdx != std::string::npos && slashIdx+1 < normalized.size()) {
-		if(check_relative_skip_dirs(normalized.substr(slashIdx+1)))
+	if (slashIdx != std::string::npos && slashIdx+1 < normalized.size()) {
+		if (check_relative_skip_dirs(normalized.substr(slashIdx+1)))
 			return true;
 	}
 	return check_absolute_skip_dirs(normalized);
diff --git a/gui/action.cpp b/gui/action.cpp
index 5ba749c..8f85e16 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -107,7 +107,7 @@
 ActionThread::~ActionThread()
 {
 	pthread_mutex_lock(&m_act_lock);
-	if(m_thread_running) {
+	if (m_thread_running) {
 		pthread_mutex_unlock(&m_act_lock);
 		pthread_join(m_thread, NULL);
 	} else {
@@ -262,7 +262,7 @@
 		if (attr)
 		{
 			std::vector<std::string> keys = TWFunc::Split_String(attr->value(), "+");
-			for(size_t i = 0; i < keys.size(); ++i)
+			for (size_t i = 0; i < keys.size(); ++i)
 			{
 				const int key = getKeyByName(keys[i]);
 				mKeys[key] = false;
@@ -297,7 +297,7 @@
 int GUIAction::NotifyKey(int key, bool down)
 {
 	std::map<int, bool>::iterator itr = mKeys.find(key);
-	if(itr == mKeys.end())
+	if (itr == mKeys.end())
 		return 1;
 
 	bool prevState = itr->second;
@@ -307,20 +307,20 @@
 	// doesn't trigger with multi-key actions.
 	// Else, check if all buttons are pressed, then consume their release events
 	// so they don't trigger one-button actions and reset mKeys pressed status
-	if(mKeys.size() == 1) {
-		if(!down && prevState) {
+	if (mKeys.size() == 1) {
+		if (!down && prevState) {
 			doActions();
 			return 0;
 		}
-	} else if(down) {
-		for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
-			if(!itr->second)
+	} else if (down) {
+		for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
+			if (!itr->second)
 				return 1;
 		}
 
 		// Passed, all req buttons are pressed, reset them and consume release events
 		HardwareKeyboard *kb = PageManager::GetHardwareKeyboard();
-		for(itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
+		for (itr = mKeys.begin(); itr != mKeys.end(); ++itr) {
 			kb->ConsumeKeyRelease(itr->first);
 			itr->second = false;
 		}
@@ -338,7 +338,7 @@
 
 	if (varName.empty() && !isConditionValid() && mKeys.empty() && !mActionW)
 		doActions();
-	else if((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
+	else if ((varName.empty() || IsConditionVariable(varName)) && isConditionValid() && isConditionTrue())
 		doActions();
 
 	return 0;
@@ -707,7 +707,7 @@
 		int divide_by = atoi(divide_by_str.c_str());
 		int value;
 
-		if(divide_by != 0)
+		if (divide_by != 0)
 		{
 			DataManager::GetValue(varName, value);
 			DataManager::SetValue(varName, value/divide_by);
@@ -855,7 +855,7 @@
 	} else {
 		DataManager::SetValue("tw_check_partition_list", 0);
 	}
-		return 0;
+	return 0;
 }
 
 int GUIAction::getpartitiondetails(std::string arg)
@@ -943,19 +943,19 @@
 	gid_t gid = -1;
 
 	struct passwd *pwd = getpwnam("media_rw");
-	if(pwd) {
+	if (pwd) {
 		uid = pwd->pw_uid;
 		gid = pwd->pw_gid;
 	}
 
 	const std::string storage = DataManager::GetCurrentStoragePath();
-	if(PartitionManager.Is_Mounted_By_Path(storage)) {
+	if (PartitionManager.Is_Mounted_By_Path(storage)) {
 		snprintf(path, sizeof(path), "%s/Pictures/Screenshots/", storage.c_str());
 	} else {
 		strcpy(path, "/tmp/");
 	}
 
-	if(!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid))
+	if (!TWFunc::Create_Dir_Recursive(path, 0775, uid, gid))
 		return 0;
 
 	tm = time(NULL);
@@ -965,7 +965,7 @@
 	strftime(path+path_len, sizeof(path)-path_len, "Screenshot_%Y-%m-%d-%H-%M-%S.png", localtime(&tm));
 
 	int res = gr_save_screenshot(path);
-	if(res == 0) {
+	if (res == 0) {
 		chmod(path, 0666);
 		chown(path, uid, gid);
 
@@ -1388,7 +1388,7 @@
 			struct timeval timeout;
 			fd_set fdset;
 
-			while(keep_going)
+			while (keep_going)
 			{
 				FD_ZERO(&fdset);
 				FD_SET(fd, &fdset);
@@ -1406,7 +1406,7 @@
 					keep_going = 0;
 				} else {
 					// Try to read output
-					if(fgets(line, sizeof(line), fp) != NULL)
+					if (fgets(line, sizeof(line), fp) != NULL)
 						gui_print("%s", line); // Display output
 					else
 						keep_going = 0; // Done executing
diff --git a/gui/animation.cpp b/gui/animation.cpp
index d45373d..37f0d08 100644
--- a/gui/animation.cpp
+++ b/gui/animation.cpp
@@ -88,7 +88,7 @@
 
 int GUIAnimation::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (!mAnimation || !mAnimation->GetResource(mFrame))	return -1;
@@ -99,7 +99,7 @@
 
 int GUIAnimation::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (!mAnimation)		return -1;
diff --git a/gui/console.cpp b/gui/console.cpp
index 6f375ff..b518e77 100644
--- a/gui/console.cpp
+++ b/gui/console.cpp
@@ -78,7 +78,7 @@
 	}
 
 	// The text after last \n (or whole string if there is no \n)
-	if(*start) {
+	if (*start) {
 		gConsole.push_back(start);
 		gConsoleColor.push_back(color);
 	}
@@ -205,7 +205,10 @@
 
 	if (!node)
 	{
-		mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
+		mRenderX = 0;
+		mRenderY = 0;
+		mRenderW = gr_fb_width();
+		mRenderH = gr_fb_height();
 	}
 	else
 	{
@@ -276,7 +279,7 @@
 
 int GUIConsole::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (mSlideout && mSlideoutState == hidden)
@@ -346,7 +349,7 @@
 //  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(!isConditionTrue())
+	if (!isConditionTrue())
 		return -1;
 
 	if (mSlideout && x >= mSlideoutX && x < mSlideoutX + mSlideoutW && y >= mSlideoutY && y < mSlideoutY + mSlideoutH) {
diff --git a/gui/fileselector.cpp b/gui/fileselector.cpp
index 9275d97..fa4ed82 100644
--- a/gui/fileselector.cpp
+++ b/gui/fileselector.cpp
@@ -127,7 +127,7 @@
 
 int GUIFileSelector::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	GUIScrollList::Update();
@@ -155,7 +155,7 @@
 {
 	GUIScrollList::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (varName.empty()) {
diff --git a/gui/fill.cpp b/gui/fill.cpp
index d0a1cfd..0fda4b4 100644
--- a/gui/fill.cpp
+++ b/gui/fill.cpp
@@ -42,7 +42,7 @@
 
 int GUIFill::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	gr_color(mColor.red, mColor.green, mColor.blue, mColor.alpha);
diff --git a/gui/gui.cpp b/gui/gui.cpp
index df41939..17ed108 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -300,15 +300,15 @@
 	// Handle key-press here
 	LOGEVENT("TOUCH_KEY: %d\n", ev.code);
 	// Left mouse button is treated as a touch
-	if(ev.code == BTN_LEFT)
+	if (ev.code == BTN_LEFT)
 	{
 		MouseCursor *cursor = PageManager::GetMouseCursor();
-		if(ev.value == 1)
+		if (ev.value == 1)
 		{
 			cursor->GetPos(x, y);
 			doTouchStart();
 		}
-		else if(touch_status)
+		else if (touch_status)
 		{
 			// Left mouse button was previously pressed and now is
 			// being released so send a TOUCH_RELEASE
@@ -323,9 +323,9 @@
 		}
 	}
 	// side mouse button, often used for "back" function
-	else if(ev.code == BTN_SIDE)
+	else if (ev.code == BTN_SIDE)
 	{
-		if(ev.value == 1)
+		if (ev.value == 1)
 			kb->KeyDown(KEY_BACK);
 		else
 			kb->KeyUp(KEY_BACK);
@@ -366,12 +366,12 @@
 	// Mouse movement
 	MouseCursor *cursor = PageManager::GetMouseCursor();
 	LOGEVENT("EV_REL %d %d\n", ev.code, ev.value);
-	if(ev.code == REL_X)
+	if (ev.code == REL_X)
 		cursor->Move(ev.value, 0);
-	else if(ev.code == REL_Y)
+	else if (ev.code == REL_Y)
 		cursor->Move(0, ev.value);
 
-	if(touch_status) {
+	if (touch_status) {
 		cursor->GetPos(x, y);
 		LOGEVENT("Mouse TOUCH_DRAG: %d, %d\n", x, y);
 		key_status = KS_NONE;
diff --git a/gui/input.cpp b/gui/input.cpp
index ec370ab..8dd981c 100644
--- a/gui/input.cpp
+++ b/gui/input.cpp
@@ -236,7 +236,7 @@
 	unsigned index = 0, displaySize = displayValue.size();
 	int prevX = mRenderX + scrollingX;
 
-	for(index = 0; index <= displaySize; index++) {
+	for (index = 0; index <= displaySize; index++) {
 		cursorString = displayValue.substr(0, index);
 		cursorX = gr_ttf_measureEx(cursorString.c_str(), fontResource) + mRenderX + scrollingX;
 		if (cursorX > x) {
@@ -263,7 +263,7 @@
 }
 
 void GUIInput::HandleCursorByText() {
-// Uses mCursorLocation to find cursorX 
+// Uses mCursorLocation to find cursorX
 	if (!DrawCursor)
 		return;
 
diff --git a/gui/listbox.cpp b/gui/listbox.cpp
index e10fee7..05276e8 100644
--- a/gui/listbox.cpp
+++ b/gui/listbox.cpp
@@ -123,7 +123,7 @@
 
 int GUIListBox::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	GUIScrollList::Update();
@@ -140,7 +140,7 @@
 {
 	GUIScrollList::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	// Check to see if the variable that we are using to store the list selected value has been updated
diff --git a/gui/mousecursor.cpp b/gui/mousecursor.cpp
index bd730df..cb5e11b 100644
--- a/gui/mousecursor.cpp
+++ b/gui/mousecursor.cpp
@@ -52,15 +52,15 @@
 	xml_node<>* child;
 
 	child = FindNode(node, "placement");
-	if(child)
+	if (child)
 		LoadPlacement(child, &mRenderX, &mRenderY, &mRenderW, &mRenderH);
 
 	child = FindNode(node, "background");
-	if(child)
+	if (child)
 	{
 		m_color = LoadAttrColor(child, "color", m_color);
 		m_image = LoadAttrImage(child, "resource");
-		if(m_image)
+		if (m_image)
 		{
 			mRenderW = m_image->GetWidth();
 			mRenderH = m_image->GetHeight();
@@ -68,20 +68,20 @@
 	}
 
 	child = FindNode(node, "speed");
-	if(child)
+	if (child)
 	{
 		attr = child->first_attribute("multiplier");
-		if(attr)
+		if (attr)
 			m_speedMultiplier = atof(attr->value());
 	}
 }
 
 int MouseCursor::Render(void)
 {
-	if(!m_present)
+	if (!m_present)
 		return 0;
 
-	if(m_image)
+	if (m_image)
 	{
 		gr_blit(m_image->GetResource(), 0, 0, mRenderW, mRenderH, mRenderX, mRenderY);
 	}
@@ -95,15 +95,15 @@
 
 int MouseCursor::Update(void)
 {
-	if(m_present != ev_has_mouse())
+	if (m_present != ev_has_mouse())
 	{
 		m_present = ev_has_mouse();
-		if(m_present)
+		if (m_present)
 			SetRenderPos(m_resX/2, m_resY/2);
 		return 2;
 	}
 
-	if(m_present && m_moved)
+	if (m_present && m_moved)
 	{
 		m_moved = false;
 		return 2;
@@ -113,7 +113,7 @@
 
 int MouseCursor::SetRenderPos(int x, int y, int w, int h)
 {
-	if(x == mRenderX && y == mRenderY)
+	if (x == mRenderX && y == mRenderY)
 		m_moved = true;
 
 	return RenderObject::SetRenderPos(x, y, w, h);
@@ -121,7 +121,7 @@
 
 void MouseCursor::Move(int deltaX, int deltaY)
 {
-	if(deltaX != 0)
+	if (deltaX != 0)
 	{
 		mRenderX += deltaX*m_speedMultiplier;
 		mRenderX = (std::min)(mRenderX, m_resX);
@@ -130,7 +130,7 @@
 		m_moved = true;
 	}
 
-	if(deltaY != 0)
+	if (deltaY != 0)
 	{
 		mRenderY += deltaY*m_speedMultiplier;
 		mRenderY = (std::min)(mRenderY, m_resY);
diff --git a/gui/object.cpp b/gui/object.cpp
index e7d1bf9..be831a7 100644
--- a/gui/object.cpp
+++ b/gui/object.cpp
@@ -159,7 +159,7 @@
 	std::vector<Condition>::iterator iter;
 	for (iter = conditions.begin(); iter != conditions.end(); ++iter)
 	{
-		if(varNameEmpty && iter->mCompareOp == "modified")
+		if (varNameEmpty && iter->mCompareOp == "modified")
 		{
 			string val;
 
@@ -172,10 +172,10 @@
 			iter->mLastVal = val;
 		}
 
-		if(varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName)
+		if (varNameEmpty || iter->mVar1 == varName || iter->mVar2 == varName)
 			iter->mLastResult = isConditionTrue(&(*iter));
 
-		if(!iter->mLastResult)
+		if (!iter->mLastResult)
 			result = false;
 	}
 	return result;
diff --git a/gui/objects.hpp b/gui/objects.hpp
index 7506277..f1c9c49 100644
--- a/gui/objects.hpp
+++ b/gui/objects.hpp
@@ -1234,8 +1234,6 @@
 FontResource* LoadAttrFont(xml_node<>* element, const char* attrname);
 ImageResource* LoadAttrImage(xml_node<>* element, const char* attrname);
 AnimationResource* LoadAttrAnimation(xml_node<>* element, const char* attrname);
-
 bool LoadPlacement(xml_node<>* node, int* x, int* y, int* w = NULL, int* h = NULL, Placement* placement = NULL);
 
 #endif  // _OBJECTS_HEADER
-
diff --git a/gui/pages.cpp b/gui/pages.cpp
index d7cb92d..5c647c3 100644
--- a/gui/pages.cpp
+++ b/gui/pages.cpp
@@ -1009,7 +1009,7 @@
 		name = child->first_attribute("name");
 		value = child->first_attribute("value");
 		persist = child->first_attribute("persist");
-		if(name && value)
+		if (name && value)
 		{
 			if (strcmp(name->value(), "tw_x_offset") == 0) {
 				tw_x_offset = atoi(value->value());
@@ -1193,7 +1193,7 @@
 		// We can try to load the XML directly...
 		LOGINFO("PageManager::LoadFileToBuffer loading filename: '%s' directly\n", filename.c_str());
 		struct stat st;
-		if(stat(filename.c_str(),&st) != 0) {
+		if (stat(filename.c_str(),&st) != 0) {
 			// This isn't always an error, sometimes we request files that don't exist.
 			return NULL;
 		}
@@ -1471,7 +1471,7 @@
 	if (iter == mPageSets.end())
 		return -1;
 
-	if(mMouseCursor)
+	if (mMouseCursor)
 		mMouseCursor->ResetData(gr_fb_width(), gr_fb_height());
 
 	PageSet* set = (*iter).second;
@@ -1589,18 +1589,18 @@
 
 int PageManager::Render(void)
 {
-	if(blankTimer.isScreenOff())
+	if (blankTimer.isScreenOff())
 		return 0;
 
 	int res = (mCurrentSet ? mCurrentSet->Render() : -1);
-	if(mMouseCursor)
+	if (mMouseCursor)
 		mMouseCursor->Render();
 	return res;
 }
 
 HardwareKeyboard *PageManager::GetHardwareKeyboard()
 {
-	if(!mHardwareKeyboard)
+	if (!mHardwareKeyboard)
 		mHardwareKeyboard = new HardwareKeyboard();
 	return mHardwareKeyboard;
 }
@@ -1630,14 +1630,14 @@
 
 MouseCursor *PageManager::GetMouseCursor()
 {
-	if(!mMouseCursor)
+	if (!mMouseCursor)
 		mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height());
 	return mMouseCursor;
 }
 
 void PageManager::LoadCursorData(xml_node<>* node)
 {
-	if(!mMouseCursor)
+	if (!mMouseCursor)
 		mMouseCursor = new MouseCursor(gr_fb_width(), gr_fb_height());
 
 	mMouseCursor->LoadData(node);
@@ -1645,7 +1645,7 @@
 
 int PageManager::Update(void)
 {
-	if(blankTimer.isScreenOff())
+	if (blankTimer.isScreenOff())
 		return 0;
 
 	if (RunReload())
@@ -1653,10 +1653,10 @@
 
 	int res = (mCurrentSet ? mCurrentSet->Update() : -1);
 
-	if(mMouseCursor)
+	if (mMouseCursor)
 	{
 		int c_res = mMouseCursor->Update();
-		if(c_res > res)
+		if (c_res > res)
 			res = c_res;
 	}
 	return res;
diff --git a/gui/partitionlist.cpp b/gui/partitionlist.cpp
index ff207fa..dca3904 100644
--- a/gui/partitionlist.cpp
+++ b/gui/partitionlist.cpp
@@ -79,7 +79,7 @@
 
 int GUIPartitionList::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	// Check for changes in mount points if the list type is mount and update the list and render if needed
@@ -101,8 +101,8 @@
 	if (updateList) {
 		int listSize = 0;
 
-		// Completely update the list if needed -- Used primarily for 
-		// restore as the list for restore will change depending on what 
+		// Completely update the list if needed -- Used primarily for
+		// restore as the list for restore will change depending on what
 		// partitions were backed up
 		mList.clear();
 		PartitionManager.Get_Partition_List(ListType, &mList);
@@ -126,7 +126,7 @@
 {
 	GUIScrollList::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (varName == mVariable && !mUpdate)
diff --git a/gui/patternpassword.cpp b/gui/patternpassword.cpp
index ab446b9..4bce37a 100644
--- a/gui/patternpassword.cpp
+++ b/gui/patternpassword.cpp
@@ -54,7 +54,7 @@
 	mAction = new GUIAction(node);
 
 	child = FindNode(node, "dot");
-	if(child)
+	if (child)
 	{
 		mDotColor = LoadAttrColor(child, "color", mDotColor);
 		mActiveDotColor = LoadAttrColor(child, "activecolor", mActiveDotColor);
@@ -65,18 +65,18 @@
 	}
 
 	child = FindNode(node, "line");
-	if(child)
+	if (child)
 	{
 		mLineColor = LoadAttrColor(child, "color", mLineColor);
 		mLineWidth = LoadAttrIntScaleX(child, "width", mLineWidth);
 	}
 
 	child = FindNode(node, "data");
-	if(child)
+	if (child)
 		mPassVar = LoadAttrString(child, "name", "");
 
 	child = FindNode(node, "size");
-	if(child) {
+	if (child) {
 		mSizeVar = LoadAttrString(child, "name", "");
 
 		// Use the configured default, if set.
@@ -84,7 +84,7 @@
 		Resize(size);
 	}
 
-	if(!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
+	if (!mDotImage || !mDotImage->GetResource() || !mActiveDotImage || !mActiveDotImage->GetResource())
 	{
 		mDotCircle = gr_render_circle(mDotRadius, mDotColor.red, mDotColor.green, mDotColor.blue, mDotColor.alpha);
 		mActiveDotCircle = gr_render_circle(mDotRadius/2, mActiveDotColor.red, mActiveDotColor.green, mActiveDotColor.blue, mActiveDotColor.alpha);
@@ -104,10 +104,10 @@
 	delete[] mDots;
 	delete[] mConnectedDots;
 
-	if(mDotCircle)
+	if (mDotCircle)
 		gr_free_surface(mDotCircle);
 
-	if(mActiveDotCircle)
+	if (mActiveDotCircle)
 		gr_free_surface(mActiveDotCircle);
 }
 
@@ -115,7 +115,7 @@
 {
 	mConnectedDotsLen = 0;
 	mCurLineX = mCurLineY = -1;
-	for(size_t i = 0; i < mGridSize * mGridSize; ++i)
+	for (size_t i = 0; i < mGridSize * mGridSize; ++i)
 		mDots[i].active = false;
 }
 
@@ -155,9 +155,9 @@
 	 *                       n*n-1
 	 */
 
-	for(size_t r = 0; r < mGridSize; ++r)
+	for (size_t r = 0; r < mGridSize; ++r)
 	{
-		for(size_t c = 0; c < mGridSize; ++c)
+		for (size_t c = 0; c < mGridSize; ++c)
 		{
 			mDots[mGridSize*r + c].x = x;
 			mDots[mGridSize*r + c].y = y;
@@ -170,29 +170,29 @@
 
 int GUIPatternPassword::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	gr_color(mLineColor.red, mLineColor.green, mLineColor.blue, mLineColor.alpha);
-	for(size_t i = 1; i < mConnectedDotsLen; ++i) {
+	for (size_t i = 1; i < mConnectedDotsLen; ++i) {
 		const Dot& dp = mDots[mConnectedDots[i-1]];
 		const Dot& dc = mDots[mConnectedDots[i]];
 		gr_line(dp.x + mDotRadius, dp.y + mDotRadius, dc.x + mDotRadius, dc.y + mDotRadius, mLineWidth);
 	}
 
-	if(mConnectedDotsLen > 0 && mTrackingTouch) {
+	if (mConnectedDotsLen > 0 && mTrackingTouch) {
 		const Dot& dc = mDots[mConnectedDots[mConnectedDotsLen-1]];
 		gr_line(dc.x + mDotRadius, dc.y + mDotRadius, mCurLineX, mCurLineY, mLineWidth);
 	}
 
-	for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
-		if(mDotCircle) {
+	for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+		if (mDotCircle) {
 			gr_blit(mDotCircle, 0, 0, gr_get_width(mDotCircle), gr_get_height(mDotCircle), mDots[i].x, mDots[i].y);
-			if(mDots[i].active) {
+			if (mDots[i].active) {
 				gr_blit(mActiveDotCircle, 0, 0, gr_get_width(mActiveDotCircle), gr_get_height(mActiveDotCircle), mDots[i].x + mDotRadius/2, mDots[i].y + mDotRadius/2);
 			}
 		} else {
-			if(mDots[i].active) {
+			if (mDots[i].active) {
 				gr_blit(mActiveDotImage->GetResource(), 0, 0, mActiveDotImage->GetWidth(), mActiveDotImage->GetHeight(),
 						mDots[i].x + (mDotRadius - mActiveDotImage->GetWidth()/2), mDots[i].y + (mDotRadius - mActiveDotImage->GetHeight()/2));
 			} else {
@@ -205,7 +205,7 @@
 
 int GUIPatternPassword::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	int res = mNeedRender ? 2 : 1;
@@ -214,7 +214,7 @@
 }
 
 void GUIPatternPassword::Resize(size_t n) {
-	if(mGridSize == n)
+	if (mGridSize == n)
 		return;
 
 	delete[] mDots;
@@ -247,8 +247,8 @@
 
 int GUIPatternPassword::InDot(int x, int y)
 {
-	for(size_t i = 0; i < mGridSize * mGridSize; ++i) {
-		if(IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
+	for (size_t i = 0; i < mGridSize * mGridSize; ++i) {
+		if (IsInCircle(x, y, mDots[i].x + mDotRadius, mDots[i].y + mDotRadius, mDotRadius*3))
 			return i;
 	}
 	return -1;
@@ -256,8 +256,8 @@
 
 bool GUIPatternPassword::DotUsed(int dot_idx)
 {
-	for(size_t i = 0; i < mConnectedDotsLen; ++i) {
-		if(mConnectedDots[i] == dot_idx)
+	for (size_t i = 0; i < mConnectedDotsLen; ++i) {
+		if (mConnectedDots[i] == dot_idx)
 			return true;
 	}
 	return false;
@@ -265,7 +265,7 @@
 
 void GUIPatternPassword::ConnectDot(int dot_idx)
 {
-	if(mConnectedDotsLen >= mGridSize * mGridSize)
+	if (mConnectedDotsLen >= mGridSize * mGridSize)
 	{
 		LOGERR("mConnectedDots in GUIPatternPassword has overflown!\n");
 		return;
@@ -277,7 +277,7 @@
 
 void GUIPatternPassword::ConnectIntermediateDots(int next_dot_idx)
 {
-	if(mConnectedDotsLen == 0)
+	if (mConnectedDotsLen == 0)
 		return;
 
 	const int prev_dot_idx = mConnectedDots[mConnectedDotsLen-1];
@@ -311,15 +311,15 @@
 	int Dy = (ny > py) ? 1 : -1;
 
 	// Vertical lines.
-	if(px == nx)
+	if (px == nx)
 		Dx = 0;
 
 	// Horizontal lines.
-	else if(py == ny)
+	else if (py == ny)
 		Dy = 0;
 
 	// Diagonal lines (|∆x| = |∆y|).
-	else if(abs(px - nx) == abs(py - ny))
+	else if (abs(px - nx) == abs(py - ny))
 		;
 
 	// No valid intermediate dots.
@@ -327,19 +327,19 @@
 		return;
 
 	// Iterate along axis, adding dots in the correct order.
-	while((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
+	while ((Dy == 0 || y != ny - Dy) && (Dx == 0 || x != nx - Dx)) {
 		x += Dx;
 		y += Dy;
 
 		int idx = mGridSize * y + x;
-		if(!DotUsed(idx))
+		if (!DotUsed(idx))
 			ConnectDot(idx);
 	}
 }
 
 int GUIPatternPassword::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return -1;
 
 	switch (state)
@@ -347,7 +347,7 @@
 		case TOUCH_START:
 		{
 			const int dot_idx = InDot(x, y);
-			if(dot_idx == -1)
+			if (dot_idx == -1)
 				break;
 
 			mTrackingTouch = true;
@@ -361,11 +361,11 @@
 		}
 		case TOUCH_DRAG:
 		{
-			if(!mTrackingTouch)
+			if (!mTrackingTouch)
 				break;
 
 			const int dot_idx = InDot(x, y);
-			if(dot_idx != -1 && !DotUsed(dot_idx))
+			if (dot_idx != -1 && !DotUsed(dot_idx))
 			{
 				ConnectIntermediateDots(dot_idx);
 				ConnectDot(dot_idx);
@@ -379,7 +379,7 @@
 		}
 		case TOUCH_RELEASE:
 		{
-			if(!mTrackingTouch)
+			if (!mTrackingTouch)
 				break;
 
 			mNeedRender = true;
@@ -396,10 +396,10 @@
 
 int GUIPatternPassword::NotifyVarChange(const std::string& varName, const std::string& value)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
-	if(varName == mSizeVar) {
+	if (varName == mSizeVar) {
 		Resize(atoi(value.c_str()));
 		mUpdate = true;
 	}
@@ -420,8 +420,8 @@
 std::string GUIPatternPassword::GeneratePassphrase()
 {
 	char pattern[mConnectedDotsLen];
-	for(size_t i = 0; i < mConnectedDotsLen; i++) {
-		 pattern[i] = (char) mConnectedDots[i];
+	for (size_t i = 0; i < mConnectedDotsLen; i++) {
+		pattern[i] = (char) mConnectedDots[i];
 	}
 
 	std::stringstream pass;
@@ -461,9 +461,9 @@
 
 void GUIPatternPassword::PatternDrawn()
 {
-	if(!mPassVar.empty() && mConnectedDotsLen > 0)
+	if (!mPassVar.empty() && mConnectedDotsLen > 0)
 		DataManager::SetValue(mPassVar, GeneratePassphrase());
 
-	if(mAction)
+	if (mAction)
 		mAction->doActions();
 }
diff --git a/gui/progressbar.cpp b/gui/progressbar.cpp
index fc2a497..c40e63e 100644
--- a/gui/progressbar.cpp
+++ b/gui/progressbar.cpp
@@ -67,7 +67,7 @@
 
 int GUIProgressBar::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	// This handles making sure timing updates occur
@@ -90,7 +90,7 @@
 
 int GUIProgressBar::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	std::string str;
@@ -165,7 +165,7 @@
 {
 	GUIObject::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	static int nextPush = 0;
diff --git a/gui/resources.cpp b/gui/resources.cpp
index 8884dd7..000912d 100644
--- a/gui/resources.cpp
+++ b/gui/resources.cpp
@@ -124,7 +124,7 @@
 
 	file = attr->value();
 
-	if(file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0)
+	if (file.size() >= 4 && file.compare(file.size()-4, 4, ".ttf") == 0)
 	{
 		int font_size = 0;
 
@@ -144,7 +144,7 @@
 		int dpi = 300;
 
 		attr = node->first_attribute("dpi");
-		if(attr)
+		if (attr)
 			dpi = atoi(attr->value());
 
 		// we can't use TMP_RESOURCE_NAME here because the ttf subsystem is caching the name and scaling needs to reload the font
@@ -166,10 +166,10 @@
 }
 
 void FontResource::DeleteFont() {
-	if(mFont)
+	if (mFont)
 		gr_ttf_freeFont(mFont);
 	mFont = NULL;
-	if(origFont)
+	if (origFont)
 		gr_ttf_freeFont(origFont);
 	origFont = NULL;
 }
diff --git a/gui/scrolllist.cpp b/gui/scrolllist.cpp
index 291b382..7540356 100644
--- a/gui/scrolllist.cpp
+++ b/gui/scrolllist.cpp
@@ -190,7 +190,7 @@
 
 int GUIScrollList::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	// First step, fill background
@@ -352,7 +352,7 @@
 
 int GUIScrollList::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (!mHeaderIsStatic) {
@@ -421,7 +421,7 @@
 
 int GUIScrollList::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return -1;
 
 	switch (state)
@@ -524,7 +524,7 @@
 {
 	// handle dragging downward, scrolling upward
 	// the offset should always be <= 0 and > -actualItemHeight, adjust the first display row and offset as needed
-	while(firstDisplayedItem && y_offset > 0) {
+	while (firstDisplayedItem && y_offset > 0) {
 		firstDisplayedItem--;
 		y_offset -= actualItemHeight;
 	}
@@ -569,7 +569,7 @@
 {
 	GUIObject::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (!mHeaderIsStatic) {
@@ -624,7 +624,7 @@
 		string curr_color;
 		if (origColor)
 			curr_color = origColor->at(i);
-		for(;;) {
+		for (;;) {
 			size_t line_char_width = gr_ttf_maxExW(curr_line.c_str(), mFont->GetResource(), mRenderW);
 			if (line_char_width < curr_line.size()) {
 				//string left = curr_line.substr(0, line_char_width);
diff --git a/gui/slider.cpp b/gui/slider.cpp
index 59b295b..1a2f59e 100644
--- a/gui/slider.cpp
+++ b/gui/slider.cpp
@@ -108,7 +108,7 @@
 
 int GUISlider::Render(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (!sSlider || !sSlider->GetResource())
@@ -136,7 +136,7 @@
 
 int GUISlider::Update(void)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return 0;
 
 	if (sUpdate)
@@ -146,7 +146,7 @@
 
 int GUISlider::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return -1;
 
 	static bool dragging = false;
diff --git a/gui/slidervalue.cpp b/gui/slidervalue.cpp
index 088620a..b53797b 100644
--- a/gui/slidervalue.cpp
+++ b/gui/slidervalue.cpp
@@ -62,7 +62,7 @@
 	}
 
 	mLabel = new GUIText(node);
-	if(mLabel->Render() < 0)
+	if (mLabel->Render() < 0)
 	{
 		delete mLabel;
 		mLabel = NULL;
@@ -156,7 +156,7 @@
 
 	mFontHeight = mFont->GetHeight();
 
-	if(mShowCurr)
+	if (mShowCurr)
 	{
 		int maxLen = std::max(strlen(mMinStr.c_str()), strlen(mMaxStr.c_str()));
 		mValueStr = new char[maxLen+1];
@@ -182,10 +182,10 @@
 
 void GUISliderValue::loadValue(bool force)
 {
-	if(!mVariable.empty())
+	if (!mVariable.empty())
 	{
 		int value = DataManager::GetIntValue(mVariable);
-		if(mValue == value && !force)
+		if (mValue == value && !force)
 			return;
 
 		mValue = value;
@@ -208,7 +208,7 @@
 	}
 
 	mRenderH = mSliderH;
-	if(mShowCurr)
+	if (mShowCurr)
 		mRenderH += mFontHeight;
 
 	if (mLabel)
@@ -230,7 +230,7 @@
 	mActionW = mRenderW;
 	mActionH = mRenderH;
 
-	if(mBackgroundImage && mBackgroundImage->GetResource())
+	if (mBackgroundImage && mBackgroundImage->GetResource())
 	{
 		mLineW = mBackgroundImage->GetWidth();
 		mLineH = mBackgroundImage->GetHeight();
@@ -260,7 +260,7 @@
 		return 0;
 	}
 
-	if(mLabel)
+	if (mLabel)
 	{
 		int w, h;
 		mLabel->GetCurrentBounds(w, h);
@@ -270,12 +270,12 @@
 			mLabel->SetRenderPos(textX, mRenderY);
 		}
 		int res = mLabel->Render();
-		if(res < 0)
+		if (res < 0)
 			return res;
 	}
 
 	// line
-	if(mBackgroundImage && mBackgroundImage->GetResource())
+	if (mBackgroundImage && mBackgroundImage->GetResource())
 	{
 		gr_blit(mBackgroundImage->GetResource(), 0, 0, mLineW, mLineH, mLineX, mLineY);
 	}
@@ -288,10 +288,10 @@
 	// slider
 	uint32_t sliderX = mLineX + (mValuePct*(mLineW - mSliderW))/100;
 
-	if(mHandleImage && mHandleImage->GetResource())
+	if (mHandleImage && mHandleImage->GetResource())
 	{
 		gr_surface s = mHandleImage->GetResource();
-		if(mDragging && mHandleHoverImage && mHandleHoverImage->GetResource())
+		if (mDragging && mHandleHoverImage && mHandleHoverImage->GetResource())
 			s = mHandleHoverImage->GetResource();
 		gr_blit(s, 0, 0, mSliderW, mSliderH, sliderX, mLineY + (mLineH/2 - mSliderH/2));
 	}
@@ -302,16 +302,16 @@
 	}
 
 	void *fontResource = NULL;
-	if(mFont) fontResource = mFont->GetResource();
+	if (mFont) fontResource = mFont->GetResource();
 	gr_color(mTextColor.red, mTextColor.green, mTextColor.blue, mTextColor.alpha);
-	if(mShowRange)
+	if (mShowRange)
 	{
 		int rangeY = (mLineY - mLineH/2) - mFontHeight/2;
 		gr_textEx_scaleW(mRenderX + mPadding/2, rangeY, mMinStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0);
 		gr_textEx_scaleW(mLineX + mLineW + mPadding/2, rangeY, mMaxStr.c_str(), fontResource, mRenderW, TOP_LEFT, 0);
 	}
 
-	if(mValueStr && mShowCurr)
+	if (mValueStr && mShowCurr)
 	{
 		sprintf(mValueStr, "%d", mValue);
 		int textW = measureText(mValueStr);
@@ -329,7 +329,7 @@
 	if (!mRendered)
 		return 2;
 
-	if(mLabel)
+	if (mLabel)
 		return mLabel->Update();
 	return 0;
 }
@@ -406,7 +406,7 @@
 		mLabel->NotifyVarChange(varName, value);
 	if (varName == mVariable) {
 		int newVal = atoi(value.c_str());
-		if(newVal != mValue) {
+		if (newVal != mValue) {
 			mValue = newVal;
 			mValuePct = pctFromValue(mValue);
 			mRendered = false;
diff --git a/gui/terminal.cpp b/gui/terminal.cpp
index b4194d0..fe80fb0 100644
--- a/gui/terminal.cpp
+++ b/gui/terminal.cpp
@@ -500,7 +500,7 @@
 		uint32_t u8state = 0, u8cp = 0;
 		std::string& s = lines[y].text;
 		unpackedLine.cells.clear();
-		for(size_t i = 0; i < s.size(); ++i) {
+		for (size_t i = 0; i < s.size(); ++i) {
 			uint32_t rc = utf8decode(&u8state, &u8cp, (unsigned char)s[i]);
 			if (rc == UTF8_ACCEPT)
 				unpackedLine.cells.push_back(Cell(u8cp));
@@ -776,7 +776,10 @@
 	lastCondition = false;
 
 	if (!node) {
-		mRenderX = 0; mRenderY = 0; mRenderW = gr_fb_width(); mRenderH = gr_fb_height();
+		mRenderX = 0;
+		mRenderY = 0;
+		mRenderW = gr_fb_width();
+		mRenderH = gr_fb_height();
 	}
 
 	engine = &gEngine;
@@ -785,7 +788,7 @@
 
 int GUITerminal::Update(void)
 {
-	if(!isConditionTrue()) {
+	if (!isConditionTrue()) {
 		lastCondition = false;
 		return 0;
 	}
@@ -816,7 +819,7 @@
 //  Return 0 on success, >0 to ignore remainder of touch, and <0 on error
 int GUITerminal::NotifyTouch(TOUCH_STATE state, int x, int y)
 {
-	if(!isConditionTrue())
+	if (!isConditionTrue())
 		return -1;
 
 	// TODO: grab focus correctly
diff --git a/gui/textbox.cpp b/gui/textbox.cpp
index 2e2512c..2c7d09f 100644
--- a/gui/textbox.cpp
+++ b/gui/textbox.cpp
@@ -98,7 +98,7 @@
 {
 	GUIScrollList::NotifyVarChange(varName, value);
 
-	if(!isConditionTrue() || mIsStatic)
+	if (!isConditionTrue() || mIsStatic)
 		return 0;
 
 	// Check to see if the variable exists in mText
diff --git a/gui/theme/common/portrait.xml b/gui/theme/common/portrait.xml
index b36b5a6..80e358b 100644
--- a/gui/theme/common/portrait.xml
+++ b/gui/theme/common/portrait.xml
@@ -386,9 +386,9 @@
 			</checkbox>
 
 			<checkbox>
-				<placement x="%indent%" y="%row13a_y%" />
+				<placement x="%indent%" y="%row13a_y%"/>
 				<text>{@install_reboot_chk=Reboot after installation is complete}</text>
-				<data variable="tw_install_reboot" />
+				<data variable="tw_install_reboot"/>
 			</checkbox>
 
 			<checkbox>
diff --git a/gui/twmsg.cpp b/gui/twmsg.cpp
index 57f1922..ebd6fc3 100644
--- a/gui/twmsg.cpp
+++ b/gui/twmsg.cpp
@@ -33,7 +33,7 @@
 {
 	const std::vector<std::string>& vars;
 	const StringLookup& next;
-	public:
+public:
 	LocalLookup(const std::vector<std::string>& vars, const StringLookup& next) : vars(vars), next(next) {}
 	virtual std::string operator()(const std::string& name) const
 	{
diff --git a/openrecoveryscript.cpp b/openrecoveryscript.cpp
index f9c610a..d94775a 100644
--- a/openrecoveryscript.cpp
+++ b/openrecoveryscript.cpp
@@ -98,8 +98,8 @@
 	FILE *fp = fopen(SCRIPT_FILE_TMP, "r");
 	int ret_val = 0, cindex, line_len, i, remove_nl, install_cmd = 0, sideload = 0;
 	char script_line[SCRIPT_COMMAND_SIZE], command[SCRIPT_COMMAND_SIZE],
-		 value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
-		 value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
+	     value[SCRIPT_COMMAND_SIZE], mount[SCRIPT_COMMAND_SIZE],
+	     value1[SCRIPT_COMMAND_SIZE], value2[SCRIPT_COMMAND_SIZE];
 	char *val_start, *tok;
 
 	if (fp != NULL) {
@@ -120,9 +120,9 @@
 			memset(command, 0, sizeof(command));
 			memset(value, 0, sizeof(value));
 			if ((int)script_line[line_len - 1] == 10)
-					remove_nl = 2;
-				else
-					remove_nl = 1;
+				remove_nl = 2;
+			else
+				remove_nl = 1;
 			if (cindex != 0) {
 				strncpy(command, script_line, cindex);
 				LOGINFO("command is: '%s'\n", command);
diff --git a/partition.cpp b/partition.cpp
index ae27fd0..9ff9061 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -2322,7 +2322,7 @@
 	while (Remain > 0) {
 		if (Remain < RW_Block_Size)
 			bs = (ssize_t)(Remain);
-		if (read(src_fd,  buffer, bs) != bs) {
+		if (read(src_fd, buffer, bs) != bs) {
 			LOGINFO("Error reading source fd (%s)\n", strerror(errno));
 			goto exit;
 		}
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 40e0863..ffa43ee 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -569,7 +569,6 @@
 	return true;
 }
 
-
 bool TWPartitionManager::Backup_Partition(PartitionSettings *part_settings) {
 	time_t start, stop;
 	int use_compression, adb_control_bu_fd;
@@ -730,7 +729,6 @@
 	if (!Mount_Current_Storage(true))
 		return false;
 
-
 	DataManager::GetValue(TW_SKIP_MD5_GENERATE_VAR, do_md5);
 	if (do_md5 == 0)
 		part_settings.generate_md5 = true;
@@ -842,7 +840,6 @@
 		part_settings.Part = Find_Partition_By_Path(backup_path);
 		if (part_settings.Part != NULL) {
 			if (!Backup_Partition(&part_settings))
-
 				return false;
 		} else {
 			gui_msg(Msg(msg::kError, "unable_to_locate_partition=Unable to locate '{1}' partition for backup calculations.")(backup_path));
@@ -920,7 +917,6 @@
 
 	time(&Start);
 
-
 	if (!part_settings->Part->Restore(part_settings)) {
 		TWFunc::SetPerformanceMode(false);
 		return false;
@@ -2078,13 +2074,13 @@
 {
 	TWPartition *res = NULL;
 	for (std::vector<TWPartition*>::iterator iter = Partitions.begin(); iter != Partitions.end(); ++iter) {
-		if(!(*iter)->Is_Storage)
+		if (!(*iter)->Is_Storage)
 			continue;
 
-		if((*iter)->Is_Settings_Storage)
+		if ((*iter)->Is_Settings_Storage)
 			return *iter;
 
-		if(!res)
+		if (!res)
 			res = *iter;
 	}
 	return res;
diff --git a/twrp-functions.cpp b/twrp-functions.cpp
index 92d3a3b..9296c34 100644
--- a/twrp-functions.cpp
+++ b/twrp-functions.cpp
@@ -64,7 +64,7 @@
 	int ret = 0;
 	exec = __popen(cmd.c_str(), "r");
 	if (!exec) return -1;
-	while(!feof(exec)) {
+	while (!feof(exec)) {
 		if (fgets(buffer, 128, exec) != NULL) {
 			result += buffer;
 		}
@@ -184,15 +184,15 @@
 	size_t _key_data_len = 0;
 
 	// mostly kanged from OpenAES oaes.c
-	for( _j = 0; _j < 32; _j++ )
+	for ( _j = 0; _j < 32; _j++ )
 		_key_data[_j] = _j + 1;
 	_key_data_len = password.size();
-	if( 16 >= _key_data_len )
+	if ( 16 >= _key_data_len )
 		_key_data_len = 16;
-	else if( 24 >= _key_data_len )
+	else if ( 24 >= _key_data_len )
 		_key_data_len = 24;
 	else
-	_key_data_len = 32;
+		_key_data_len = 32;
 	memcpy(_key_data, password.c_str(), password.size());
 
 	ctx = oaes_alloc();
@@ -282,13 +282,13 @@
 	std::string res;
 	size_t last_idx = 0, idx = 0;
 
-	while(last_idx != std::string::npos)
+	while (last_idx != std::string::npos)
 	{
-		if(last_idx != 0)
+		if (last_idx != 0)
 			res += '/';
 
 		idx = path.find_first_of('/', last_idx);
-		if(idx == std::string::npos) {
+		if (idx == std::string::npos) {
 			res += path.substr(last_idx, idx);
 			break;
 		}
@@ -297,7 +297,7 @@
 		last_idx = path.find_first_not_of('/', idx);
 	}
 
-	if(leaveLast)
+	if (leaveLast)
 		res += '/';
 	return res;
 }
@@ -318,13 +318,13 @@
 	string field;
 	istringstream f(in);
 	if (del == '\n') {
-		while(getline(f, field)) {
+		while (getline(f, field)) {
 			if (field.empty() && skip_empty)
 				continue;
-		res.push_back(field);
+			res.push_back(field);
 		}
 	} else {
-		while(getline(f, field, del)) {
+		while (getline(f, field, del)) {
 			if (field.empty() && skip_empty)
 				continue;
 			res.push_back(field);
@@ -894,44 +894,44 @@
 	struct dirent *dt;
 	std::string ats_path;
 
-	if(!PartitionManager.Mount_By_Path("/data", false))
+	if (!PartitionManager.Mount_By_Path("/data", false))
 		return;
 
 	// Prefer ats_2, it seems to be the one we want according to logcat on hammerhead
 	// - it is the one for ATS_TOD (time of day?).
 	// However, I never saw a device where the offset differs between ats files.
-	for(size_t i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i)
+	for (size_t i = 0; i < (sizeof(paths)/sizeof(paths[0])); ++i)
 	{
 		DIR *d = opendir(paths[i]);
-		if(!d)
+		if (!d)
 			continue;
 
-		while((dt = readdir(d)))
+		while ((dt = readdir(d)))
 		{
-			if(dt->d_type != DT_REG || strncmp(dt->d_name, "ats_", 4) != 0)
+			if (dt->d_type != DT_REG || strncmp(dt->d_name, "ats_", 4) != 0)
 				continue;
 
-			if(ats_path.empty() || strcmp(dt->d_name, "ats_2") == 0)
+			if (ats_path.empty() || strcmp(dt->d_name, "ats_2") == 0)
 				ats_path = std::string(paths[i]).append(dt->d_name);
 		}
 
 		closedir(d);
 	}
 
-	if(ats_path.empty())
+	if (ats_path.empty())
 	{
 		LOGINFO("TWFunc::Fixup_Time: no ats files found, leaving untouched!\n");
 		return;
 	}
 
 	f = fopen(ats_path.c_str(), "r");
-	if(!f)
+	if (!f)
 	{
 		LOGINFO("TWFunc::Fixup_Time: failed to open file %s\n", ats_path.c_str());
 		return;
 	}
 
-	if(fread(&offset, sizeof(offset), 1, f) != 1)
+	if (fread(&offset, sizeof(offset), 1, f) != 1)
 	{
 		LOGINFO("TWFunc::Fixup_Time: failed load uint64 from file %s\n", ats_path.c_str());
 		fclose(f);
@@ -946,7 +946,7 @@
 	tv.tv_sec += offset/1000;
 	tv.tv_usec += (offset%1000)*1000;
 
-	while(tv.tv_usec >= 1000000)
+	while (tv.tv_usec >= 1000000)
 	{
 		++tv.tv_sec;
 		tv.tv_usec -= 1000000;
@@ -964,13 +964,13 @@
 	std::vector<std::string> res;
 	size_t idx = 0, idx_last = 0;
 
-	while(idx < str.size())
+	while (idx < str.size())
 	{
 		idx = str.find_first_of(delimiter, idx_last);
-		if(idx == std::string::npos)
+		if (idx == std::string::npos)
 			idx = str.size();
 
-		if(idx-idx_last != 0 || !removeEmpty)
+		if (idx-idx_last != 0 || !removeEmpty)
 			res.push_back(str.substr(idx_last, idx-idx_last));
 
 		idx_last = idx + delimiter.size();
@@ -984,12 +984,12 @@
 	std::vector<std::string> parts = Split_String(path, "/");
 	std::string cur_path;
 	struct stat info;
-	for(size_t i = 0; i < parts.size(); ++i)
+	for (size_t i = 0; i < parts.size(); ++i)
 	{
 		cur_path += "/" + parts[i];
-		if(stat(cur_path.c_str(), &info) < 0 || !S_ISDIR(info.st_mode))
+		if (stat(cur_path.c_str(), &info) < 0 || !S_ISDIR(info.st_mode))
 		{
-			if(mkdir(cur_path.c_str(), mode) < 0)
+			if (mkdir(cur_path.c_str(), mode) < 0)
 				return false;
 			chown(cur_path.c_str(), uid, gid);
 		}
diff --git a/twrp.cpp b/twrp.cpp
index 3531279..b247458 100644
--- a/twrp.cpp
+++ b/twrp.cpp
@@ -254,7 +254,7 @@
 		printf("\n");
 	}
 
-	if(crash_counter == 0) {
+	if (crash_counter == 0) {
 		property_list(Print_Prop, NULL);
 		printf("\n");
 	} else {
@@ -309,7 +309,7 @@
 	GUIConsole::Translate_Now();
 
 	// Fixup the RTC clock on devices which require it
-	if(crash_counter == 0)
+	if (crash_counter == 0)
 		TWFunc::Fixup_Time_On_Boot();
 
 	// Run any outstanding OpenRecoveryScript
diff --git a/twrpTar.cpp b/twrpTar.cpp
index 27c7c7b..4a71159 100644
--- a/twrpTar.cpp
+++ b/twrpTar.cpp
@@ -987,7 +987,7 @@
 				fd = pipes[1];
 				init_libtar_no_buffer(progress_pipe_fd);
 				tar_type.writefunc = write_tar_no_buffer;
-				if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+				if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
 					close(fd);
 					LOGINFO("tar_fdopen failed\n");
 					gui_err("backup_error=Error creating backup.");
@@ -1047,7 +1047,7 @@
 			fd = pigzfd[1];   // copy parent output
 			init_libtar_no_buffer(progress_pipe_fd);
 			tar_type.writefunc = write_tar_no_buffer;
-			if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+			if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
 				close(fd);
 				LOGINFO("tar_fdopen failed\n");
 				gui_err("backup_error=Error creating backup.");
@@ -1097,7 +1097,7 @@
 			fd = oaesfd[1];   // copy parent output
 			init_libtar_no_buffer(progress_pipe_fd);
 			tar_type.writefunc = write_tar_no_buffer;
-			if(tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+			if (tar_fdopen(&t, fd, charRootDir, &tar_type, O_WRONLY | O_CREAT | O_EXCL | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
 				close(fd);
 				LOGINFO("tar_fdopen failed\n");
 				gui_err("backup_error=Error creating backup.");
@@ -1220,7 +1220,7 @@
 				close(pipes[1]);
 				close(pipes[3]);
 				fd = pipes[2];
-				if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+				if (tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
 					close(fd);
 					LOGINFO("tar_fdopen failed\n");
 					gui_err("restore_error=Error during restore process.");
@@ -1270,7 +1270,7 @@
 			// Parent
 			close(oaesfd[1]); // close parent output
 			fd = oaesfd[0];   // copy parent input
-			if(tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
+			if (tar_fdopen(&t, fd, charRootDir, NULL, O_RDONLY | O_LARGEFILE, S_IRUSR | S_IWUSR | S_IRGRP | S_IWGRP | S_IROTH | S_IWOTH, TWTAR_FLAGS) != 0) {
 				close(fd);
 				LOGINFO("tar_fdopen failed\n");
 				gui_err("restore_error=Error during restore process.");
@@ -1536,7 +1536,7 @@
 			*/
 			split = TWFunc::split_string(result, ' ', true);
 			if (split.size() > 4)
-			total_size = atoi(split[5].c_str());
+				total_size = atoi(split[5].c_str());
 		}
 	} else if (current_archive_type == COMPRESSED_ENCRYPTED) {
 		// File is encrypted and may be compressed
@@ -1562,7 +1562,7 @@
 				*/
 				split = TWFunc::split_string(result, ' ', true);
 				if (split.size() > 4)
-				total_size = atoi(split[5].c_str());
+					total_size = atoi(split[5].c_str());
 			}
 		} else {
 			total_size = TWFunc::Get_File_Size(filename);
diff --git a/twrpTar.h b/twrpTar.h
index 425a831..2348487 100644
--- a/twrpTar.h
+++ b/twrpTar.h
@@ -23,4 +23,3 @@
 ssize_t write_tar_no_buffer(int fd, const void *buffer, size_t size);
 
 #endif  // _TWRPTAR_HEADER
-
diff --git a/twrpTar.hpp b/twrpTar.hpp
index 78c4c59..92674ee 100644
--- a/twrpTar.hpp
+++ b/twrpTar.hpp
@@ -44,7 +44,6 @@
 	unsigned thread_id;
 };
 
-
 class twrpTar {
 public:
 	twrpTar();