Various fixes

Modify AOSP mount and wipe functions to use Partition Manager.
Update wipe code to reset the log file index when wiping cache.
Add ADB sideload to 540x960 theme.
diff --git a/gui/devices/540x960/res/ui.xml b/gui/devices/540x960/res/ui.xml
index 0d7fa3e..3987641 100644
--- a/gui/devices/540x960/res/ui.xml
+++ b/gui/devices/540x960/res/ui.xml
@@ -44,6 +44,7 @@
 		<variable name="col1_x" value="10" />
 		<variable name="col2_x" value="277" />
 		<variable name="col_center_x" value="143" />
+		<variable name="col_center_medium_x" value="206" />
 		<variable name="center_x" value="270" />
 		<variable name="row1_y" value="140" />
 		<variable name="row2_y" value="332" />
@@ -785,6 +786,9 @@
 				<action function="set">tw_has_action2=0</action>
 				<action function="set">tw_action2=</action>
 				<action function="set">tw_action2_param=</action>
+				<action function="set">tw_has_cancel=0</action>
+				<action function="set">tw_cancel_action=</action>
+				<action function="set">tw_cancel_param=</action>
 				<action function="page">%tw_clear_destination%</action>
 			</object>
 		</page>
@@ -867,6 +871,15 @@
 
 			<object type="template" name="action_page_console" />
 
+			<object type="button">
+				<condition var1="tw_has_cancel" var2="1" />
+				<placement x="%col_center_medium_x%" y="%row4_y%" />
+				<font resource="font" color="%button_text_color%" />
+				<text>Cancel</text>
+				<image resource="medium_button" />
+				<action function="%tw_cancel_action%">%tw_cancel_param%</action>
+			</object>
+
 			<object type="template" name="progress_bar" />
 
 			<object type="action">
@@ -2531,6 +2544,31 @@
 			</object>
 
 			<object type="button">
+				<placement x="%col2_x%" y="%row3_y%" />
+				<font resource="font" color="%button_text_color%" />
+				<text>Reload Theme</text>
+				<image resource="main_button" />
+				<action function="reload"></action>
+			</object>
+
+			<object type="button">
+				<placement x="%col1_x%" y="%row4_y%" />
+				<font resource="font" color="%button_text_color%" />
+				<text>ADB Sideload</text>
+				<image resource="main_button" />
+				<actions>
+					<action function="set">tw_back=advanced</action>
+					<action function="set">tw_action=adbsideload</action>
+					<action function="set">tw_action_text1=ADB Sideload</action>
+					<action function="set">tw_action_text2=Usage: adb sideload filename.zip</action>
+					<action function="set">tw_complete_text1=ADB Sideload Complete</action>
+					<action function="set">tw_has_cancel=1</action>
+					<action function="set">tw_cancel_action=adbsideloadcancel</action>
+					<action function="page">action_page</action>
+				</actions>
+			</object>
+
+			<object type="button">
 				<condition var1="tw_show_dumlock" var2="1" />
 				<placement x="%col2_x%" y="%row4_y%" />
 				<font resource="font" color="%button_text_color%" />
diff --git a/partition.cpp b/partition.cpp
index ad3198b..341dee7 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -42,6 +42,7 @@
 	#include "mtdutils/mtdutils.h"
 	#include "mtdutils/mounts.h"
 	#include "makelist.h"
+	#include "extra-functions.h"
 }
 
 TWPartition::TWPartition(void) {
@@ -217,16 +218,19 @@
 			Wipe_During_Factory_Reset = true;
 			Display_Name = "SD-Ext";
 			Wipe_Available_in_GUI = true;
+			Removable = true;
 		}
 #ifdef TW_EXTERNAL_STORAGE_PATH
 		if (Mount_Point == EXPAND(TW_EXTERNAL_STORAGE_PATH)) {
 			Is_Storage = true;
 			Storage_Path = EXPAND(TW_EXTERNAL_STORAGE_PATH);
+			Removable = true;
 		}
 #else
 		if (Mount_Point == "/sdcard") {
 			Is_Storage = true;
 			Storage_Path = "/sdcard";
+			Removable = true;
 		}
 #endif
 #ifdef TW_INTERNAL_STORAGE_PATH
@@ -662,6 +666,9 @@
 		return false;
 	}
 
+	if (Mount_Point == "/cache")
+		tmplog_offset = 0;
+
 	if (Has_Data_Media)
 		return Wipe_Data_Without_Wiping_Media();
 
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index 2bcbc27..2e0219e 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -413,11 +413,10 @@
 	if (!generate_md5)
 		return true;
 
-	ui_print(" * Generating md5...");
+	ui_print(" * Generating md5...\n");
 
 	if (TWFunc::Path_Exists(Full_File)) {
 		sprintf(command, "cd '%s' && md5sum %s > %s.md5",Backup_Folder.c_str(), Backup_Filename.c_str(), Backup_Filename.c_str());
-		LOGI("MD5 command is: '%s'\n", command);
 		if (system(command) == 0) {
 			ui_print("MD5 Created.\n");
 			return true;
@@ -432,7 +431,6 @@
 		sprintf(filename, "%s%03i", Full_File.c_str(), index);
 		while (TWFunc::Path_Exists(filename) == true) {
 			sprintf(command, "cd '%s' && md5sum %s%03i > %s%03i.md5",Backup_Folder.c_str(), Backup_Filename.c_str(), index, Backup_Filename.c_str(), index);
-			LOGI("MD5 command is: '%s'\n", command);
 			if (system(command) != 0) {
 				ui_print("MD5 Error.\n");
 				return false;
diff --git a/roots.cpp b/roots.cpp
index 69c98fc..9cbaa49 100644
--- a/roots.cpp
+++ b/roots.cpp
@@ -29,6 +29,7 @@
 #include "roots.h"
 #include "common.h"
 #include "make_ext4fs.h"
+#include "partitions.hpp"
 
 static int num_volumes = 0;
 static Volume* device_volumes = NULL;
@@ -142,6 +143,10 @@
 }
 
 int ensure_path_mounted(const char* path) {
+	if (PartitionManager.Mount_By_Path(path, true))
+		return 0;
+	else
+		return -1;
     Volume* v = volume_for_path(path);
     if (v == NULL) {
         LOGE("unknown volume for path [%s]\n", path);
@@ -202,6 +207,10 @@
 }
 
 int ensure_path_unmounted(const char* path) {
+	if (PartitionManager.UnMount_By_Path(path, true))
+		return 0;
+	else
+		return -1;
     Volume* v = volume_for_path(path);
     if (v == NULL) {
         LOGE("unknown volume for path [%s]\n", path);
@@ -230,6 +239,10 @@
 }
 
 int format_volume(const char* volume) {
+	if (PartitionManager.Wipe_By_Path(volume))
+		return 0;
+	else
+		return -1;
     Volume* v = volume_for_path(volume);
     if (v == NULL) {
         LOGE("unknown volume \"%s\"\n", volume);
diff --git a/twinstall.cpp b/twinstall.cpp
index af53256..4bc6942 100644
--- a/twinstall.cpp
+++ b/twinstall.cpp
@@ -287,7 +287,7 @@
 			LOGE("No MD5 file found for '%s'.\nDisable force MD5 check to avoid this error.\n", path);
 			return INSTALL_CORRUPT;
 		} else
-			ui_print("No MD5 file found, this is not an error.\n");
+			ui_print("Skipping MD5 check: no MD5 file found.\n");
 	} else if (md5_return == 1)
 		ui_print("Zip MD5 matched.\n"); // MD5 found and matched.