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();
