diff --git a/data.cpp b/data.cpp
index 1b5c1ff..92e2e41 100644
--- a/data.cpp
+++ b/data.cpp
@@ -150,7 +150,7 @@
     if (mBackingFile.empty())       return -1;
 
 	string mount_path = GetSettingsStoragePath();
-	TWPartitionManager::Mount_By_Path(mount_path.c_str(), 1);
+	PartitionManager.Mount_By_Path(mount_path.c_str(), 1);
 
 	FILE* out = fopen(mBackingFile.c_str(), "wb");
     if (!out)                       return -1;
@@ -672,10 +672,10 @@
 	sprintf(mkdir_path, "%s/TWRP", DataManager_GetSettingsStoragePath());
 	sprintf(settings_file, "%s/.twrps", mkdir_path);
 
-	if (TWPartitionManager::Mount_By_Path(DataManager_GetSettingsStorageMount(), 0) < 0)
+	if (!PartitionManager.Mount_Settings_Storage(false))
 	{
 		usleep(500000);
-		if (TWPartitionManager::Mount_By_Path(DataManager_GetSettingsStorageMount(), 0) < 0)
+		if (!PartitionManager.Mount_Settings_Storage(false))
 			LOGE("Unable to mount %s when trying to read settings file.\n", DataManager_GetSettingsStorageMount());
 	}
 
@@ -688,14 +688,14 @@
 	GetValue(TW_HAS_EXTERNAL, has_ext);
 	if (has_dual != 0 && use_ext == 1) {
 		// Attempt to sdcard using external storage
-		if (TWPartitionManager::Mount_Current_Storage()) {
+		if (PartitionManager.Mount_Current_Storage(false)) {
 			LOGE("Failed to mount external storage, using internal storage.\n");
 			// Remount failed, default back to internal storage
 			SetValue(TW_USE_EXTERNAL_STORAGE, 0);
-			TWPartitionManager::Mount_Current_Storage();
+			PartitionManager.Mount_Current_Storage(true);
 		}
 	} else {
-		TWPartitionManager::Mount_Current_Storage();
+		PartitionManager.Mount_Current_Storage(true);
 	}
 	if (has_data_media == 1) {
 		if (has_dual == 0) {
@@ -731,7 +731,7 @@
 		string ext_path;
 
 		GetValue(TW_EXTERNAL_PATH, ext_path);
-		TWPartitionManager::Mount_By_Path(ext_path, 0);
+		PartitionManager.Mount_By_Path(ext_path, 0);
 	}
 }
 
diff --git a/extra-functions.h b/extra-functions.h
index 83a4318..6d2a085 100644
--- a/extra-functions.h
+++ b/extra-functions.h
@@ -6,7 +6,7 @@
 int __pclose(FILE *iop);
 
 // Device ID variable / function
-char device_id[64];
+extern char device_id[64];
 void get_device_id();
 static char* copy_sideloaded_package(const char* original_path);
 int install_zip_package(const char* zip_path_filename);
diff --git a/gui/Android.mk b/gui/Android.mk
index f73a2e5..a19a63e 100644
--- a/gui/Android.mk
+++ b/gui/Android.mk
@@ -19,8 +19,7 @@
     slider.cpp \
     listbox.cpp \
     keyboard.cpp \
-    input.cpp \
-    gui-functions.c
+    input.cpp
 
 ifneq ($(TWRP_CUSTOM_KEYBOARD),)
   LOCAL_SRC_FILES += $(TWRP_CUSTOM_KEYBOARD)
diff --git a/gui/action.cpp b/gui/action.cpp
index ed39d60..db4c9c4 100644
--- a/gui/action.cpp
+++ b/gui/action.cpp
@@ -25,7 +25,7 @@
 #include "../tw_reboot.h"
 #include "../minuitwrp/minui.h"
 #include "../recovery_ui.h"
-#include "gui-functions.h"
+#include "../extra-functions.h"
 #include "../variables.h"
 
 int install_zip_package(const char* zip_path_filename);
@@ -355,7 +355,7 @@
 
 		operation_start("Reload Theme");
 		theme_path = DataManager::GetSettingsStoragePath();
-		if (TWPartitionManager::Mount_By_Path(theme_path.c_str(), 1) < 0) {
+		if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
 			LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
 			check = 1;
 		}
@@ -378,7 +378,7 @@
     {
 		string Restore_Name;
 		DataManager::GetValue("tw_restore", Restore_Name);
-		TWPartitionManager::Set_Restore_Files(Restore_Name);
+		PartitionManager.Set_Restore_Files(Restore_Name);
         return 0;
     }
 
@@ -465,8 +465,8 @@
 			ui_print("Simulating actions...\n");
 		else {
 			DataManager::ResetDefaults();
-			TWPartitionManager::Update_System_Details();
-			TWPartitionManager::Mount_Current_Storage();
+			PartitionManager.Update_System_Details();
+			PartitionManager.Mount_Current_Storage(true);
 		}
 		operation_end(0, simulate);
 	}
@@ -478,7 +478,7 @@
 		{
 			char command[255];
 
-			TWPartitionManager::Mount_Current_Storage();
+			PartitionManager.Mount_Current_Storage(true);
 			sprintf(command, "cp /tmp/recovery.log %s", DataManager::GetCurrentStoragePath().c_str());
 			__system(command);
 			sync();
@@ -549,7 +549,7 @@
 		} else if (arg == "external") {
 			DataManager::SetValue(TW_USE_EXTERNAL_STORAGE, 1);
 		}
-		if (TWPartitionManager::Mount_Current_Storage() == 0) {
+		if (PartitionManager.Mount_Settings_Storage(true)) {
 			if (arg == "internal") {
 				// Save the current zip location to the external variable
 				DataManager::SetValue(TW_ZIP_EXTERNAL_VAR, DataManager::GetStrValue(TW_ZIP_LOCATION_VAR));
@@ -673,7 +673,7 @@
 				simulate_progress_bar();
 			} else {
 				if (arg == "data")
-					TWPartitionManager::Factory_Reset();
+					PartitionManager.Factory_Reset();
 				else if (arg == "battery")
 					wipe_battery_stats();
 				else if (arg == "rotate")
@@ -696,7 +696,7 @@
 
 					DataManager::GetValue(TW_HAS_DATA_MEDIA, has_datamedia);
 					if (has_datamedia) {
-						TWPartitionManager::Mount_By_Path("/data", 1);
+						PartitionManager.Mount_By_Path("/data", 1);
 						__system("rm -rf /data/media");
 						__system("cd /data && mkdir media && chmod 775 media");
 						DataManager::GetValue(TW_HAS_DUAL_STORAGE, dual_storage);
@@ -712,15 +712,15 @@
 					ret_val = 0;
 					LOGE("Wipe not implemented yet!\n");
 				} else
-					TWPartitionManager::Wipe_By_Path(arg);
+					PartitionManager.Wipe_By_Path(arg);
 
 				if (arg == "/sdcard") {
-					TWPartitionManager::Mount_By_Path("/sdcard", 1);
+					PartitionManager.Mount_By_Path("/sdcard", 1);
 					mkdir("/sdcard/TWRP", 0777);
 					DataManager::Flush();
 				}
 			}
-			TWPartitionManager::Update_System_Details();
+			PartitionManager.Update_System_Details();
 			if (ret_val != 0)
 				ret_val = 1;
             operation_end(ret_val, simulate);
@@ -732,7 +732,7 @@
 			if (simulate) {
 				simulate_progress_bar();
 			} else
-				TWPartitionManager::Update_System_Details();
+				PartitionManager.Update_System_Details();
 			operation_end(0, simulate);
 		}
         if (function == "nandroid")
@@ -747,14 +747,14 @@
 					string Backup_Name;
 					DataManager::GetValue(TW_BACKUP_NAME, Backup_Name);
 					if (Backup_Name == "(Current Date)" || Backup_Name == "0" || Backup_Name == "(" || check_backup_name(1))
-						TWPartitionManager::Run_Backup(Backup_Name);
+						PartitionManager.Run_Backup(Backup_Name);
 					else
 						return -1;
 					DataManager::SetValue(TW_BACKUP_NAME, "(Current Date)");
 				} else if (arg == "restore") {
 					string Restore_Name;
 					DataManager::GetValue("tw_restore", Restore_Name);
-					TWPartitionManager::Run_Restore(Restore_Name);
+					PartitionManager.Run_Restore(Restore_Name);
 				} else {
 					operation_end(1, simulate);
 					return -1;
@@ -828,12 +828,12 @@
 					
 					// recreate TWRP folder and rewrite settings - these will be gone after sdcard is partitioned
 #ifdef TW_EXTERNAL_STORAGE_PATH
-					TWPartitionManager::Mount_By_Path(EXPAND(TW_EXTERNAL_STORAGE_PATH));
+					PartitionManager.Mount_By_Path(EXPAND(TW_EXTERNAL_STORAGE_PATH), 1);
 					DataManager::GetValue(TW_EXTERNAL_PATH, sd_path);
 					memset(mkdir_path, 0, sizeof(mkdir_path));
 					sprintf(mkdir_path, "%s/TWRP", sd_path.c_str());
 #else
-					TWPartitionManager::Mount_By_Path("/sdcard", 1);
+					PartitionManager.Mount_By_Path("/sdcard", 1);
 					strcpy(mkdir_path, "/sdcard/TWRP");
 #endif
 					mkdir(mkdir_path, 0777);
@@ -858,7 +858,7 @@
 						ui_print("DONE\n");
 					}
 
-					TWPartitionManager::Update_System_Details();
+					PartitionManager.Update_System_Details();
 				}
 			}
 			operation_end(0, simulate);
@@ -999,7 +999,7 @@
 			} else {
 				string Password;
 				DataManager::GetValue("tw_crypto_password", Password);
-				op_status = TWPartitionManager::Decrypt_Device(Password);
+				op_status = PartitionManager.Decrypt_Device(Password);
 				if (op_status != 0)
 					op_status = 1;
 				else {
@@ -1028,7 +1028,7 @@
 							std::string theme_path;
 
 							theme_path = DataManager::GetSettingsStoragePath();
-							if (TWPartitionManager::Mount_By_Path(theme_path.c_str(), 1) < 0) {
+							if (PartitionManager.Mount_By_Path(theme_path.c_str(), 1) < 0) {
 								LOGE("Unable to mount %s during reload function startup.\n", theme_path.c_str());
 								check = 1;
 							}
diff --git a/gui/gui-functions.c b/gui/gui-functions.c
deleted file mode 100644
index 53b78f9..0000000
--- a/gui/gui-functions.c
+++ /dev/null
@@ -1,860 +0,0 @@
-/*
- * Copyright (C) 2011 The Android Open Source Project
- *
- * Licensed under the Apache License, Version 2.0 (the "License");
- * you may not use this file except in compliance with the License.
- * You may obtain a copy of the License at
- *
- *      http://www.apache.org/licenses/LICENSE-2.0
- *
- * Unless required by applicable law or agreed to in writing, software
- * distributed under the License is distributed on an "AS IS" BASIS,
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
- * See the License for the specific language governing permissions and
- * limitations under the License.
- */
-
-#include <assert.h>
-#include <errno.h>
-#include <fcntl.h>
-#include <limits.h>
-#include <paths.h>
-#include <stdio.h>
-#include <stdlib.h>
-#include <string.h>
-#include <sys/stat.h>
-#include <sys/types.h>
-#include <sys/wait.h>
-#include <unistd.h>
-
-#include <ctype.h>
-#include "cutils/misc.h"
-#include "cutils/properties.h"
-#include <dirent.h>
-#include <getopt.h>
-#include <linux/input.h>
-#include <signal.h>
-#include <sys/limits.h>
-#include <termios.h>
-#include <time.h>
-#include <sys/vfs.h>
-
-#include "../tw_reboot.h"
-#include "../bootloader.h"
-#include "../common.h"
-#include "gui-functions.h"
-#include "cutils/properties.h"
-#include "../install.h"
-#include "../minuitwrp/minui.h"
-#include "../minzip/DirUtil.h"
-#include "../minzip/Zip.h"
-#include "../recovery_ui.h"
-#include "../roots.h"
-#include "../data.h"
-#include "../variables.h"
-
-//kang system() from bionic/libc/unistd and rename it __system() so we can be even more hackish :)
-#undef _PATH_BSHELL
-#define _PATH_BSHELL "/sbin/sh"
-
-static const char *SIDELOAD_TEMP_DIR = "/tmp/sideload";
-extern char **environ;
-
-int __system(const char *command) {
-  pid_t pid;
-	sig_t intsave, quitsave;
-	sigset_t mask, omask;
-	int pstat;
-	char *argp[] = {"sh", "-c", NULL, NULL};
-
-	if (!command)		/* just checking... */
-		return(1);
-
-	argp[2] = (char *)command;
-
-	sigemptyset(&mask);
-	sigaddset(&mask, SIGCHLD);
-	sigprocmask(SIG_BLOCK, &mask, &omask);
-	switch (pid = vfork()) {
-	case -1:			/* error */
-		sigprocmask(SIG_SETMASK, &omask, NULL);
-		return(-1);
-	case 0:				/* child */
-		sigprocmask(SIG_SETMASK, &omask, NULL);
-		execve(_PATH_BSHELL, argp, environ);
-    _exit(127);
-  }
-
-	intsave = (sig_t)  bsd_signal(SIGINT, SIG_IGN);
-	quitsave = (sig_t) bsd_signal(SIGQUIT, SIG_IGN);
-	pid = waitpid(pid, (int *)&pstat, 0);
-	sigprocmask(SIG_SETMASK, &omask, NULL);
-	(void)bsd_signal(SIGINT, intsave);
-	(void)bsd_signal(SIGQUIT, quitsave);
-	return (pid == -1 ? -1 : pstat);
-}
-
-static struct pid {
-	struct pid *next;
-	FILE *fp;
-	pid_t pid;
-} *pidlist;
-
-FILE *__popen(const char *program, const char *type) {
-	struct pid * volatile cur;
-	FILE *iop;
-	int pdes[2];
-	pid_t pid;
-
-	if ((*type != 'r' && *type != 'w') || type[1] != '\0') {
-		errno = EINVAL;
-		return (NULL);
-	}
-
-	if ((cur = malloc(sizeof(struct pid))) == NULL)
-		return (NULL);
-
-	if (pipe(pdes) < 0) {
-		free(cur);
-		return (NULL);
-	}
-
-	switch (pid = vfork()) {
-	case -1:			/* Error. */
-		(void)close(pdes[0]);
-		(void)close(pdes[1]);
-		free(cur);
-		return (NULL);
-		/* NOTREACHED */
-	case 0:				/* Child. */
-	    {
-		struct pid *pcur;
-		/*
-		 * because vfork() instead of fork(), must leak FILE *,
-		 * but luckily we are terminally headed for an execl()
-		 */
-		for (pcur = pidlist; pcur; pcur = pcur->next)
-			close(fileno(pcur->fp));
-
-		if (*type == 'r') {
-			int tpdes1 = pdes[1];
-
-			(void) close(pdes[0]);
-			/*
-			 * We must NOT modify pdes, due to the
-			 * semantics of vfork.
-			 */
-			if (tpdes1 != STDOUT_FILENO) {
-				(void)dup2(tpdes1, STDOUT_FILENO);
-				(void)close(tpdes1);
-				tpdes1 = STDOUT_FILENO;
-			}
-		} else {
-			(void)close(pdes[1]);
-			if (pdes[0] != STDIN_FILENO) {
-				(void)dup2(pdes[0], STDIN_FILENO);
-				(void)close(pdes[0]);
-			}
-		}
-		execl(_PATH_BSHELL, "sh", "-c", program, (char *)NULL);
-		_exit(127);
-		/* NOTREACHED */
-	    }
-	}
-
-	/* Parent; assume fdopen can't fail. */
-	if (*type == 'r') {
-		iop = fdopen(pdes[0], type);
-		(void)close(pdes[1]);
-	} else {
-		iop = fdopen(pdes[1], type);
-		(void)close(pdes[0]);
-	}
-
-	/* Link into list of file descriptors. */
-	cur->fp = iop;
-	cur->pid =  pid;
-	cur->next = pidlist;
-	pidlist = cur;
-
-	return (iop);
-}
-
-/*
- * pclose --
- *	Pclose returns -1 if stream is not associated with a `popened' command,
- *	if already `pclosed', or waitpid returns an error.
- */
-int __pclose(FILE *iop) {
-	struct pid *cur, *last;
-	int pstat;
-	pid_t pid;
-
-	/* Find the appropriate file pointer. */
-	for (last = NULL, cur = pidlist; cur; last = cur, cur = cur->next)
-		if (cur->fp == iop)
-			break;
-
-	if (cur == NULL)
-		return (-1);
-
-	(void)fclose(iop);
-
-	do {
-		pid = waitpid(cur->pid, &pstat, 0);
-	} while (pid == -1 && errno == EINTR);
-
-	/* Remove the entry from the linked list. */
-	if (last == NULL)
-		pidlist = cur->next;
-	else
-		last->next = cur->next;
-	free(cur);
-
-	return (pid == -1 ? -1 : pstat);
-}
-
-char* sanitize_device_id(char* id) {
-        const char* whitelist ="abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ1234567890-._";
-        char* c = id;
-        char* str = (int*) calloc(50, sizeof *id);
-        while (*c)
-        {
-                if (strchr(whitelist, *c))
-                {
-                        strncat(str, c, 1);
-                }
-                c++;
-        }
-        return str;
-}
-
-#define CMDLINE_SERIALNO        "androidboot.serialno="
-#define CMDLINE_SERIALNO_LEN    (strlen(CMDLINE_SERIALNO))
-#define CPUINFO_SERIALNO        "Serial"
-#define CPUINFO_SERIALNO_LEN    (strlen(CPUINFO_SERIALNO))
-#define CPUINFO_HARDWARE        "Hardware"
-#define CPUINFO_HARDWARE_LEN    (strlen(CPUINFO_HARDWARE))
-
-char* get_path (char* path) {
-        char *s;
-
-        /* Go to the end of the string.  */
-        s = path + strlen(path) - 1;
-
-        /* Strip off trailing /s (unless it is also the leading /).  */
-        while (path < s && s[0] == '/')
-                s--;
-
-        /* Strip the last component.  */
-        while (path <= s && s[0] != '/')
-                s--;
-
-        while (path < s && s[0] == '/')
-                s--;
-
-        if (s < path)
-                return ".";
-
-        s[1] = '\0';
-	return path;
-}
-
-char* basename(char* name) {
-	const char* base;	
-	for (base = name; *name; name++)
-	{
-		if(*name == '/')
-		{
-			base = name + 1;
-		}		
-	}
-	return (char *) base;
-}
-
-/*
-    Checks md5 for a path
-    Return values:
-        -1 : MD5 does not exist
-        0 : Failed
-        1 : Success
-*/
-int check_md5(char* path) {
-    int o; 
-    char cmd[PATH_MAX + 30];
-    char md5file[PATH_MAX + 40];
-    strcpy(md5file, path);
-    strcat(md5file, ".md5");
-    char dirpath[PATH_MAX];
-    char* file;
-    if (access(md5file, F_OK ) != -1) {
-	strcpy(dirpath, md5file);
-	get_path(dirpath);
-	chdir(dirpath);
-	file = basename(md5file);
-	sprintf(cmd, "/sbin/busybox md5sum -c '%s'", file);
-	FILE * cs = __popen(cmd, "r");
-	char cs_s[PATH_MAX + 50];
-	fgets(cs_s, PATH_MAX + 50, cs);
-	char* OK = strstr(cs_s, "OK");
-	if (OK != NULL) {
-		printf("MD5 is good. returning 1\n");
-		o = 1;
-	}
-	else {
-		printf("MD5 is bad. return -2\n");
-		o = -2;
-	}
-
-	__pclose(cs);
-    } 
-    else {
-	//No md5 file
-	printf("setting o to -1\n");
-	o = -1;
-    }
-
-    return o;
-}
-
-static void set_sdcard_update_bootloader_message() {
-    struct bootloader_message boot;
-    memset(&boot, 0, sizeof(boot));
-    strlcpy(boot.command, "boot-recovery", sizeof(boot.command));
-    strlcpy(boot.recovery, "recovery\n", sizeof(boot.recovery));
-    set_bootloader_message(&boot);
-}
-
-static char* copy_sideloaded_package(const char* original_path) {
-  if (ensure_path_mounted(original_path) != 0) {
-    LOGE("Can't mount %s\n", original_path);
-    return NULL;
-  }
-
-  if (ensure_path_mounted(SIDELOAD_TEMP_DIR) != 0) {
-    LOGE("Can't mount %s\n", SIDELOAD_TEMP_DIR);
-    return NULL;
-  }
-
-  if (mkdir(SIDELOAD_TEMP_DIR, 0700) != 0) {
-    if (errno != EEXIST) {
-      LOGE("Can't mkdir %s (%s)\n", SIDELOAD_TEMP_DIR, strerror(errno));
-      return NULL;
-    }
-  }
-
-  // verify that SIDELOAD_TEMP_DIR is exactly what we expect: a
-  // directory, owned by root, readable and writable only by root.
-  struct stat st;
-  if (stat(SIDELOAD_TEMP_DIR, &st) != 0) {
-    LOGE("failed to stat %s (%s)\n", SIDELOAD_TEMP_DIR, strerror(errno));
-    return NULL;
-  }
-  if (!S_ISDIR(st.st_mode)) {
-    LOGE("%s isn't a directory\n", SIDELOAD_TEMP_DIR);
-    return NULL;
-  }
-  if ((st.st_mode & 0777) != 0700) {
-    LOGE("%s has perms %o\n", SIDELOAD_TEMP_DIR, st.st_mode);
-    return NULL;
-  }
-  if (st.st_uid != 0) {
-    LOGE("%s owned by %lu; not root\n", SIDELOAD_TEMP_DIR, st.st_uid);
-    return NULL;
-  }
-
-  char copy_path[PATH_MAX];
-  strcpy(copy_path, SIDELOAD_TEMP_DIR);
-  strcat(copy_path, "/package.zip");
-
-  char* buffer = malloc(BUFSIZ);
-  if (buffer == NULL) {
-    LOGE("Failed to allocate buffer\n");
-    return NULL;
-  }
-
-  size_t read;
-  FILE* fin = fopen(original_path, "rb");
-  if (fin == NULL) {
-    LOGE("Failed to open %s (%s)\n", original_path, strerror(errno));
-    return NULL;
-  }
-  FILE* fout = fopen(copy_path, "wb");
-  if (fout == NULL) {
-    LOGE("Failed to open %s (%s)\n", copy_path, strerror(errno));
-    return NULL;
-  }
-
-  while ((read = fread(buffer, 1, BUFSIZ, fin)) > 0) {
-    if (fwrite(buffer, 1, read, fout) != read) {
-      LOGE("Short write of %s (%s)\n", copy_path, strerror(errno));
-      return NULL;
-    }
-  }
-
-  free(buffer);
-
-  if (fclose(fout) != 0) {
-    LOGE("Failed to close %s (%s)\n", copy_path, strerror(errno));
-    return NULL;
-  }
-
-  if (fclose(fin) != 0) {
-    LOGE("Failed to close %s (%s)\n", original_path, strerror(errno));
-    return NULL;
-  }
-
-  // "adb push" is happy to overwrite read-only files when it's
-  // running as root, but we'll try anyway.
-  if (chmod(copy_path, 0400) != 0) {
-    LOGE("Failed to chmod %s (%s)\n", copy_path, strerror(errno));
-    return NULL;
-  }
-
-  return strdup(copy_path);
-}
-
-int install_zip_package(const char* zip_path_filename) {
-	int result = 0;
-
-    //mount_current_storage();
-	int md5_req = DataManager_GetIntValue(TW_FORCE_MD5_CHECK_VAR);
-	if (md5_req == 1) {
-		ui_print("\n-- Verify md5 for %s", zip_path_filename);
-		int md5chk = check_md5((char*) zip_path_filename);
-		if (md5chk == 1) {
-			ui_print("\n-- Md5 verified, continue");
-			result = 0;
-		}
-		else if (md5chk == -1) {
-			if (md5_req == 1) {
-				ui_print("\n-- No md5 file found!");
-				ui_print("\n-- Aborting install");
-				result = INSTALL_ERROR;
-			}
-			else {
-				ui_print("\n-- No md5 file found, ignoring");
-			}
-		}
-		else if (md5chk == -2) {
-			ui_print("\n-- md5 file doesn't match!");
-			ui_print("\n-- Aborting install");
-			result = INSTALL_ERROR;
-		}
-		printf("%d\n", result);
-	}
-	if (result != INSTALL_ERROR) {
-		ui_print("\n-- Install %s ...\n", zip_path_filename);
-		set_sdcard_update_bootloader_message();
-		char* copy;
-		if (DataManager_GetIntValue(TW_FLASH_ZIP_IN_PLACE) == 1 && strlen(zip_path_filename) > 6 && strncmp(zip_path_filename, "/cache", 6) != 0) {
-			copy = strdup(zip_path_filename);
-		} else {
-			copy = copy_sideloaded_package(zip_path_filename);
-			//unmount_current_storage();
-		}
-		if (copy) {
-			result = really_install_package(copy, 0);
-			free(copy);
-			//update_system_details();
-		} else {
-			result = INSTALL_ERROR;
-		}
-	}
-    //mount_current_storage();
-    //finish_recovery(NULL);
-	return result;
-}
-
-//partial kangbang from system/vold
-#ifndef CUSTOM_LUN_FILE
-#define CUSTOM_LUN_FILE "/sys/devices/platform/usb_mass_storage/lun%d/file"
-#endif
-
-int usb_storage_enable(void)
-{
-    int fd;
-	char lun_file[255];
-
-	if (DataManager_GetIntValue(TW_HAS_DUAL_STORAGE) == 1 && DataManager_GetIntValue(TW_HAS_DATA_MEDIA) == 0) {
-		Volume *vol = volume_for_path(DataManager_GetSettingsStoragePath());
-		if (!vol)
-		{
-			LOGE("Unable to locate volume information.");
-			return -1;
-		}
-
-		sprintf(lun_file, CUSTOM_LUN_FILE, 0);
-
-		if ((fd = open(lun_file, O_WRONLY)) < 0)
-		{
-			LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			return -1;
-		}
-
-		if ((write(fd, vol->device, strlen(vol->device)) < 0) &&
-			(!vol->device2 || (write(fd, vol->device, strlen(vol->device2)) < 0))) {
-			LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			close(fd);
-			return -1;
-		}
-		close(fd);
-
-		Volume *vol2 = volume_for_path(DataManager_GetStrValue(TW_EXTERNAL_PATH));
-		if (!vol)
-		{
-			LOGE("Unable to locate volume information.\n");
-			return -1;
-		}
-
-		sprintf(lun_file, CUSTOM_LUN_FILE, 1);
-
-		if ((fd = open(lun_file, O_WRONLY)) < 0)
-		{
-			LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			return -1;
-		}
-
-		if ((write(fd, vol2->device, strlen(vol2->device)) < 0) &&
-			(!vol2->device2 || (write(fd, vol2->device, strlen(vol2->device2)) < 0))) {
-			LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			close(fd);
-			return -1;
-		}
-		close(fd);
-	} else {
-		if (DataManager_GetIntValue(TW_HAS_DATA_MEDIA) == 0)
-			strcpy(lun_file, DataManager_GetCurrentStoragePath());
-		else
-			strcpy(lun_file, DataManager_GetStrValue(TW_EXTERNAL_PATH));
-
-		Volume *vol = volume_for_path(lun_file);
-		if (!vol)
-		{
-			LOGE("Unable to locate volume information.\n");
-			return -1;
-		}
-
-		sprintf(lun_file, CUSTOM_LUN_FILE, 0);
-
-		if ((fd = open(lun_file, O_WRONLY)) < 0)
-		{
-			LOGE("Unable to open ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			return -1;
-		}
-
-		if ((write(fd, vol->device, strlen(vol->device)) < 0) &&
-			(!vol->device2 || (write(fd, vol->device, strlen(vol->device2)) < 0))) {
-			LOGE("Unable to write to ums lunfile '%s': (%s)\n", lun_file, strerror(errno));
-			close(fd);
-			return -1;
-		}
-		close(fd);
-	}
-	return 0;
-}
-
-int usb_storage_disable(void)
-{
-    int fd, index;
-	char lun_file[255];
-
-	for (index=0; index<2; index++) {
-		sprintf(lun_file, CUSTOM_LUN_FILE, index);
-
-		if ((fd = open(lun_file, O_WRONLY)) < 0)
-		{
-			if (index == 0)
-				LOGE("Unable to open ums lunfile '%s': (%s)", lun_file, strerror(errno));
-			return -1;
-		}
-
-		char ch = 0;
-		if (write(fd, &ch, 1) < 0)
-		{
-			if (index == 0)
-				LOGE("Unable to write to ums lunfile '%s': (%s)", lun_file, strerror(errno));
-			close(fd);
-			return -1;
-		}
-
-		close(fd);
-	}
-    return 0;
-}
-
-void wipe_dalvik_cache()
-{
-        //ui_set_background(BACKGROUND_ICON_WIPE);
-        ensure_path_mounted("/data");
-        ensure_path_mounted("/cache");
-        ui_print("\n-- Wiping Dalvik Cache Directories...\n");
-        __system("rm -rf /data/dalvik-cache");
-        ui_print("Cleaned: /data/dalvik-cache...\n");
-        __system("rm -rf /cache/dalvik-cache");
-        ui_print("Cleaned: /cache/dalvik-cache...\n");
-        __system("rm -rf /cache/dc");
-        ui_print("Cleaned: /cache/dc\n");
-
-        struct stat st;
-		LOGE("TODO: Re-implement wipe dalvik into Partition Manager!\n");
-        if (1) //if (0 != stat(sde.blk, &st))
-        {
-            ui_print("/sd-ext not present, skipping\n");
-        } else {
-        	__system("mount /sd-ext");
-    	    LOGI("Mounting /sd-ext\n");
-    	    if (stat("/sd-ext/dalvik-cache",&st) == 0)
-    	    {
-                __system("rm -rf /sd-ext/dalvik-cache");
-        	    ui_print("Cleaned: /sd-ext/dalvik-cache...\n");
-    	    }
-        }
-        ensure_path_unmounted("/data");
-        ui_print("-- Dalvik Cache Directories Wipe Complete!\n\n");
-        //ui_set_background(BACKGROUND_ICON_MAIN);
-        //if (!ui_text_visible()) return;
-}
-
-// BATTERY STATS
-void wipe_battery_stats()
-{
-    ensure_path_mounted("/data");
-    struct stat st;
-    if (0 != stat("/data/system/batterystats.bin", &st))
-    {
-        ui_print("No Battery Stats Found. No Need To Wipe.\n");
-    } else {
-        //ui_set_background(BACKGROUND_ICON_WIPE);
-        remove("/data/system/batterystats.bin");
-        ui_print("Cleared: Battery Stats...\n");
-        ensure_path_unmounted("/data");
-    }
-}
-
-// ROTATION SETTINGS
-void wipe_rotate_data()
-{
-    //ui_set_background(BACKGROUND_ICON_WIPE);
-    ensure_path_mounted("/data");
-    __system("rm -r /data/misc/akmd*");
-    __system("rm -r /data/misc/rild*");
-    ui_print("Cleared: Rotatation Data...\n");
-    ensure_path_unmounted("/data");
-}   
-
-void fix_perms()
-{
-	ensure_path_mounted("/data");
-	ensure_path_mounted("/system");
-	//ui_show_progress(1,30);
-    ui_print("\n-- Fixing Permissions\n");
-	ui_print("This may take a few minutes.\n");
-	__system("./sbin/fix_permissions.sh");
-	ui_print("-- Done.\n\n");
-	//ui_reset_progress();
-}
-
-int get_battery_level(void)
-{
-    static int lastVal = -1;
-    static time_t nextSecCheck = 0;
-
-    struct timeval curTime;
-    gettimeofday(&curTime, NULL);
-    if (curTime.tv_sec > nextSecCheck)
-    {
-        char cap_s[4];
-        FILE * cap = fopen("/sys/class/power_supply/battery/capacity","rt");
-        if (cap)
-        {
-            fgets(cap_s, 4, cap);
-            fclose(cap);
-            lastVal = atoi(cap_s);
-            if (lastVal > 100)  lastVal = 101;
-            if (lastVal < 0)    lastVal = 0;
-        }
-        nextSecCheck = curTime.tv_sec + 60;
-    }
-    return lastVal;
-}
-
-char* 
-print_batt_cap()  {
-	char* full_cap_s = (char*)malloc(30);
-	char full_cap_a[30];
-	
-	int cap_i = get_battery_level();
-    
-    //int len = strlen(cap_s);
-	//if (cap_s[len-1] == '\n') {
-	//	cap_s[len-1] = 0;
-	//}
-	
-	// Get a usable time
-	struct tm *current;
-	time_t now;
-	now = time(0);
-	current = localtime(&now);
-	
-	sprintf(full_cap_a, "Battery Level: %i%% @ %02D:%02D", cap_i, current->tm_hour, current->tm_min);
-	strcpy(full_cap_s, full_cap_a);
-	
-	return full_cap_s;
-}
-
-void update_tz_environment_variables() {
-    setenv("TZ", DataManager_GetStrValue(TW_TIME_ZONE_VAR), 1);
-    tzset();
-}
-
-void run_script(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5, const char *str6, const char *str7, int request_confirm)
-{
-	ui_print("%s", str1);
-        //ui_clear_key_queue();
-	ui_print("\nPress Power to confirm,");
-       	ui_print("\nany other key to abort.\n");
-	int confirm;
-	/*if (request_confirm) // this option is used to skip the confirmation when the gui is in use
-		confirm = ui_wait_key();
-	else*/
-		confirm = KEY_POWER;
-	
-		if (confirm == BTN_MOUSE || confirm == KEY_POWER || confirm == SELECT_ITEM) {
-                	ui_print("%s", str2);
-		        pid_t pid = fork();
-                	if (pid == 0) {
-                		char *args[] = { "/sbin/sh", "-c", (char*)str3, "1>&2", NULL };
-                	        execv("/sbin/sh", args);
-                	        fprintf(stderr, str4, strerror(errno));
-                	        _exit(-1);
-                	}
-			int status;
-			while (waitpid(pid, &status, WNOHANG) == 0) {
-				ui_print(".");
-               		        sleep(1);
-			}
-                	ui_print("\n");
-			if (!WIFEXITED(status) || (WEXITSTATUS(status) != 0)) {
-                		ui_print("%s", str5);
-                	} else {
-                		ui_print("%s", str6);
-                	}
-		} else {
-	       		ui_print("%s", str7);
-       	        }
-		//if (!ui_text_visible()) return;
-}
-
-void install_htc_dumlock(void)
-{
-	struct statfs fs1, fs2;
-	int need_libs = 0;
-
-	ui_print("Installing HTC Dumlock to system...\n");
-	ensure_path_mounted("/system");
-	__system("cp /res/htcd/htcdumlocksys /system/bin/htcdumlock && chmod 755 /system/bin/htcdumlock");
-	if (statfs("/system/bin/flash_image", &fs1) != 0) {
-		ui_print("Installing flash_image...\n");
-		__system("cp /res/htcd/flash_imagesys /system/bin/flash_image && chmod 755 /system/bin/flash_image");
-		need_libs = 1;
-	} else
-		ui_print("flash_image is already installed, skipping...\n");
-	if (statfs("/system/bin/dump_image", &fs2) != 0) {
-		ui_print("Installing dump_image...\n");
-		__system("cp /res/htcd/dump_imagesys /system/bin/dump_image && chmod 755 /system/bin/dump_image");
-		need_libs = 1;
-	} else
-		ui_print("dump_image is already installed, skipping...\n");
-	if (need_libs) {
-		ui_print("Installing libs needed for flash_image and dump_image...\n");
-		__system("cp /res/htcd/libbmlutils.so /system/lib && chmod 755 /system/lib/libbmlutils.so");
-		__system("cp /res/htcd/libflashutils.so /system/lib && chmod 755 /system/lib/libflashutils.so");
-		__system("cp /res/htcd/libmmcutils.so /system/lib && chmod 755 /system/lib/libmmcutils.so");
-		__system("cp /res/htcd/libmtdutils.so /system/lib && chmod 755 /system/lib/libmtdutils.so");
-	}
-	ui_print("Installing HTC Dumlock app...\n");
-	ensure_path_mounted("/data");
-	mkdir("/data/app", 0777);
-	__system("rm /data/app/com.teamwin.htcdumlock*");
-	__system("cp /res/htcd/HTCDumlock.apk /data/app/com.teamwin.htcdumlock.apk");
-	sync();
-	ui_print("HTC Dumlock is installed.\n");
-}
-
-void htc_dumlock_restore_original_boot(void)
-{
-	ui_print("Restoring original boot...\n");
-	__system("htcdumlock restore");
-	ui_print("Original boot restored.\n");
-}
-
-void htc_dumlock_reflash_recovery_to_boot(void)
-{
-	ui_print("Reflashing recovery to boot...\n");
-	__system("htcdumlock recovery noreboot");
-	ui_print("Recovery is flashed to boot.\n");
-}
-
-void check_and_run_script(const char* script_file, const char* display_name)
-{
-	// Check for and run startup script if script exists
-	struct statfs st;
-	if (statfs(script_file, &st) == 0) {
-		ui_print("Running %s script...\n", display_name);
-		char command[255];
-		strcpy(command, "chmod 755 ");
-		strcat(command, script_file);
-		__system(command);
-		__system(script_file);
-		ui_print("\nFinished running %s script.\n", display_name);
-	}
-}
-
-int check_backup_name(int show_error) {
-	// Check the backup name to ensure that it is the correct size and contains only valid characters
-	// and that a backup with that name doesn't already exist
-	char backup_name[MAX_BACKUP_NAME_LEN];
-	char backup_loc[255], tw_image_dir[255];
-	int copy_size = strlen(DataManager_GetStrValue(TW_BACKUP_NAME));
-	int index, cur_char;
-	struct statfs st;
-
-	// Check size
-	if (copy_size > MAX_BACKUP_NAME_LEN) {
-		if (show_error)
-			LOGE("Backup name is too long.\n");
-		return -2;
-	}
-
-	// Check characters
-	strncpy(backup_name, DataManager_GetStrValue(TW_BACKUP_NAME), copy_size);
-	if (strcmp(backup_name, "0") == 0)
-		return 0; // A "0" (zero) means to use the current timestamp for the backup name
-	for (index=0; index<copy_size; index++) {
-		cur_char = (int)backup_name[index];
-		if ((cur_char >= 48  && cur_char <= 57) || (cur_char >= 65 && cur_char <= 91) || cur_char == 93 || cur_char == 95 || (cur_char >= 97 && cur_char <= 123) || cur_char == 125 || cur_char == 45 || cur_char == 46) {
-			// These are valid characters
-			// Numbers
-			// Upper case letters
-			// Lower case letters
-			// and -_.{}[]
-		} else {
-			if (show_error)
-				LOGE("Backup name '%s' contains invalid character: '%c'\n", backup_name, (char)cur_char);
-			return -3;
-		}
-	}
-
-	// Check to make sure that a backup with this name doesn't already exist
-	strcpy(backup_loc, DataManager_GetStrValue(TW_BACKUPS_FOLDER_VAR));
-	sprintf(tw_image_dir,"%s/%s/.", backup_loc, backup_name);
-    if (statfs(tw_image_dir, &st) == 0) {
-		if (show_error)
-			LOGE("A backup with this name already exists.\n");
-		return -4;
-	}
-
-	// No problems found, return 0
-	return 0;
-}
diff --git a/gui/gui-functions.h b/gui/gui-functions.h
deleted file mode 100644
index 6bbf5ac..0000000
--- a/gui/gui-functions.h
+++ /dev/null
@@ -1,36 +0,0 @@
-#ifndef _EXTRAFUNCTIONS_HEADER
-#define _EXTRAFUNCTIONS_HEADER
-
-int __system(const char *command);
-FILE * __popen(const char *program, const char *type);
-int __pclose(FILE *iop);
-
-// Device ID variable / function
-//char device_id[64];
-//void get_device_id();
-static char* copy_sideloaded_package(const char* original_path);
-int install_zip_package(const char* zip_path_filename);
-
-void wipe_dalvik_cache();
-void wipe_battery_stats();
-void wipe_rotate_data();
-
-static long tmplog_offset = 0;
-
-// Battery level
-char* print_batt_cap();
-
-void update_tz_environment_variables();
-
-void fix_perms();
-
-void run_script(const char *str1, const char *str2, const char *str3, const char *str4, const char *str5, const char *str6, const char *str7, int request_confirm);
-
-void install_htc_dumlock(void);
-void htc_dumlock_restore_original_boot(void);
-void htc_dumlock_reflash_recovery_to_boot(void);
-
-void check_and_run_script(const char* script_file, const char* display_name);
-int check_backup_name(int show_error);
-
-#endif // _EXTRAFUNCTIONS_HEADER
diff --git a/gui/gui.cpp b/gui/gui.cpp
index cb2b7c1..ccde9f0 100644
--- a/gui/gui.cpp
+++ b/gui/gui.cpp
@@ -47,6 +47,7 @@
 #include "objects.hpp"
 #include "../data.hpp"
 #include "../variables.h"
+#include "../partitions.hpp"
 
 #include "curtain.h"
 
@@ -508,34 +509,26 @@
 //    gRecorder = open("/sdcard/video.bin", O_CREAT | O_WRONLY);
 
 	int check = 0;
-	DataManager::GetValue(TW_HAS_CRYPTO, check);
+	DataManager::GetValue(TW_IS_ENCRYPTED, check);
 	if (check) {
-		if (ensure_path_mounted("/data") < 0) {
-			// Data failed to mount - probably encrypted
-			DataManager::SetValue(TW_IS_ENCRYPTED, 1);
-			DataManager::SetValue(TW_CRYPTO_PASSWORD, "");
-			DataManager::SetValue("tw_crypto_display", "");
-			if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "decrypt"))
-			{
-				LOGE("Failed to load base packages.\n");
-				goto error;
-			} else
-				check = 1;
+		if (PageManager::LoadPackage("TWRP", "/res/ui.xml", "decrypt"))
+		{
+			LOGE("Failed to load base packages.\n");
+			goto error;
 		} else
-			check = 0; // Data mounted, not ecrypted, keep going like normal
+			check = 1;
 	}
 	if (check == 0 && PageManager::LoadPackage("TWRP", "/script/ui.xml", "main")) {
 		std::string theme_path;
 
 		theme_path = DataManager::GetSettingsStoragePath();
-		if (ensure_path_mounted(theme_path.c_str()) < 0) {
+		if (!PartitionManager.Mount_Settings_Storage(false)) {
 			int retry_count = 5;
-			while (retry_count > 0 && (ensure_path_mounted(theme_path.c_str()) < 0)) {
+			while (retry_count > 0 && !PartitionManager.Mount_Settings_Storage(false)) {
 				usleep(500000);
-				ensure_path_mounted(theme_path.c_str());
 				retry_count--;
 			}
-			if (ensure_path_mounted(theme_path.c_str()) < 0) {
+			if (!PartitionManager.Mount_Settings_Storage(false)) {
 				LOGE("Unable to mount %s during GUI startup.\n", theme_path.c_str());
 				check = 1;
 			}
diff --git a/partition.cpp b/partition.cpp
index a01e2a7..29a20dc 100644
--- a/partition.cpp
+++ b/partition.cpp
@@ -25,11 +25,19 @@
 #include <string.h>
 #include <sys/stat.h>
 #include <sys/vfs.h>
+#include <sys/mount.h>
 #include <unistd.h>
 
 #include "variables.h"
 #include "common.h"
 #include "partitions.hpp"
+#include "data.hpp"
+extern "C" {
+	#include "extra-functions.h"
+	int __system(const char *command);
+	FILE * __popen(const char *program, const char *type);
+	int __pclose(FILE *iop);
+}
 
 TWPartition::TWPartition(void) {
 	Can_Be_Mounted = false;
@@ -69,31 +77,439 @@
 	// Do nothing
 }
 
-bool TWPartition::Process_Fstab_Line(string Line) {
-	LOGI("STUB TWPartition::Process_Fstab_Line, Line: '%s'\n", Line.c_str());
+bool TWPartition::Process_Fstab_Line(string Line, bool Display_Error) {
+	char full_line[MAX_FSTAB_LINE_LENGTH], item[MAX_FSTAB_LINE_LENGTH];
+	int line_len = Line.size(), index = 0, item_index = 0;
+	char* ptr;
+
+	strncpy(full_line, Line.c_str(), line_len);
+
+	while (index < line_len) {
+		if (full_line[index] <= 32)
+			full_line[index] = '\0';
+		index++;
+	}
+	string mount_pt(full_line);
+	Mount_Point = mount_pt;
+	index = Mount_Point.size();
+	while (index < line_len) {
+		while (index < line_len && full_line[index] == '\0')
+			index++;
+		if (index >= line_len)
+			continue;
+		ptr = full_line + index;
+		if (item_index == 0) {
+			// File System
+			Fstab_File_System = ptr;
+			Current_File_System = ptr;
+			item_index++;
+		} else if (item_index == 1) {
+			// Primary Block Device
+			if (*ptr != '/') {
+				if (Display_Error)
+					LOGE("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
+				else
+					LOGI("Invalid block device on '%s', '%s', %i\n", Line.c_str(), ptr, index);
+				return 0;
+			}
+			Block_Device = ptr;
+			Find_Real_Block_Device(Block_Device, Display_Error);
+			item_index++;
+		} else if (item_index > 1) {
+			if (*ptr == '/') {
+				// Alternate Block Device
+				Alternate_Block_Device = ptr;
+				Find_Real_Block_Device(Alternate_Block_Device, Display_Error);
+			} else if (strlen(ptr) > 7 && strncmp(ptr, "length=", 7) == 0) {
+				// Partition length
+				ptr += 7;
+				Length = atoi(ptr);
+			} else {
+				// Unhandled data
+				LOGI("Unhandled fstab information: '%s', %i\n", ptr, index);
+			}
+		}
+		while (index < line_len && full_line[index] != '\0')
+			index++;
+	}
+
+	if (!Is_File_System(Fstab_File_System) && !Is_Image(Fstab_File_System)) {
+		if (Display_Error)
+			LOGE("Unknown File System: '%s'\n", Fstab_File_System.c_str());
+		else
+			LOGI("Unknown File System: '%s'\n", Fstab_File_System.c_str());
+		return 0;
+	} else if (Is_File_System(Fstab_File_System)) {
+		Setup_File_System(Display_Error);
+		if (Mount_Point == "/system") {
+			Display_Name = "System";
+			Wipe_Available_in_GUI = true;
+			Update_Size(Display_Error);
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_SYSTEM_SIZE, backup_display_size);
+		} else if (Mount_Point == "/data") {
+			Display_Name = "Data";
+			Wipe_Available_in_GUI = true;
+#ifdef RECOVERY_SDCARD_ON_DATA
+			Has_Data_Media = true;
+#endif
+#ifdef TW_INCLUDE_CRYPTO
+			Can_Be_Encrypted = true;
+			if (!Mount(false)) {
+				Is_Encrypted = true;
+				Is_Decrypted = false;
+				DataManager::SetValue(TW_IS_ENCRYPTED, 1);
+				DataManager::SetValue(TW_CRYPTO_PASSWORD, "");
+				DataManager::SetValue("tw_crypto_display", "");
+			} else
+				Update_Size(Display_Error);
+#else
+			Update_Size(Display_Error);
+#endif
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_DATA_SIZE, backup_display_size);
+		} else if (Mount_Point == "/cache") {
+			Display_Name = "Cache";
+			Wipe_Available_in_GUI = true;
+			Update_Size(Display_Error);
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_CACHE_SIZE, backup_display_size);
+		} else if (Mount_Point == "/datadata") {
+			Display_Name = "DataData";
+			Is_SubPartition = true;
+			SubPartition_Of = "/data";
+			Update_Size(Display_Error);
+			DataManager::SetValue(TW_HAS_DATADATA, 1);
+		} else if (Mount_Point == "/sd-ext") {
+			Display_Name = "SD-Ext";
+			Wipe_Available_in_GUI = true;
+			Update_Size(Display_Error);
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_SDEXT_SIZE, backup_display_size);
+			if (Backup_Size == 0) {
+				DataManager::SetValue(TW_HAS_SDEXT_PARTITION, 0);
+				DataManager::SetValue(TW_BACKUP_SDEXT_VAR, 0);
+			} else
+				DataManager::SetValue(TW_HAS_SDEXT_PARTITION, 1);
+		} else
+			Update_Size(Display_Error);
+	} else if (Is_Image(Fstab_File_System)) {
+		Setup_Image(Display_Error);
+		if (Mount_Point == "/boot") {
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_BOOT_SIZE, backup_display_size);
+			if (Backup_Size == 0) {
+				DataManager::SetValue(TW_HAS_BOOT_PARTITION, 0);
+				DataManager::SetValue(TW_BACKUP_BOOT_VAR, 0);
+			} else
+				DataManager::SetValue(TW_HAS_BOOT_PARTITION, 1);
+		} else if (Mount_Point == "/recovery") {
+			int backup_display_size = (int)(Backup_Size / 1048576LLU);
+			DataManager::SetValue(TW_BACKUP_RECOVERY_SIZE, backup_display_size);
+			if (Backup_Size == 0) {
+				DataManager::SetValue(TW_HAS_RECOVERY_PARTITION, 0);
+				DataManager::SetValue(TW_BACKUP_RECOVERY_VAR, 0);
+			} else
+				DataManager::SetValue(TW_HAS_RECOVERY_PARTITION, 1);
+		}
+	}
+
 	return 1;
 }
 
-bool TWPartition::Is_Mounted(void) {
-	LOGI("STUB TWPartition::Is_Mounted\n");
-	return 1;
+bool TWPartition::Is_File_System(string File_System) {
+	if (File_System == "ext2" ||
+	    File_System == "ext3" ||
+		File_System == "ext4" ||
+		File_System == "vfat" ||
+		File_System == "ntfs" ||
+		File_System == "yaffs2" ||
+		File_System == "auto")
+		return true;
+	else
+		return false;
 }
 
-bool TWPartition::Mount(bool Display_Error) {
-	LOGI("STUB TWPartition::Mount, Display_Error: %i\n", Display_Error);
-	if (Is_Mounted()) {
-		return 1;
+bool TWPartition::Is_Image(string File_System) {
+	if (File_System == "emmc" ||
+	    File_System == "mtd")
+		return true;
+	else
+		return false;
+}
+
+void TWPartition::Setup_File_System(bool Display_Error) {
+	struct statfs st;
+
+	Can_Be_Mounted = true;
+	Can_Be_Wiped = true;
+
+	// Check to see if the block device exists
+	if (Path_Exists(Block_Device)) {
+		Is_Present = true;
+	} else if (Alternate_Block_Device != "" && Path_Exists(Alternate_Block_Device)) {
+		Flip_Block_Device();
+		Is_Present = true;
+	}
+	// Make the mount point folder if it doesn't exist
+	if (!Path_Exists(Mount_Point.c_str())) {
+		if (mkdir(Mount_Point.c_str(), 0777) == -1) {
+			if (Display_Error)
+				LOGE("Can not create '%s' folder.\n", Mount_Point.c_str());
+			else
+				LOGI("Can not create '%s' folder.\n", Mount_Point.c_str());
+		} else
+			LOGI("Created '%s' folder.\n", Mount_Point.c_str());
+	}
+	Display_Name = Mount_Point.substr(1, Mount_Point.size() - 1);
+	Backup_Name = Display_Name;
+	Backup_Method = FILES;
+}
+
+void TWPartition::Setup_Image(bool Display_Error) {
+	if (Path_Exists(Block_Device)) {
+		Is_Present = true;
+	} else if (Alternate_Block_Device != "" && Path_Exists(Alternate_Block_Device)) {
+		Flip_Block_Device();
+		Is_Present = true;
+	}
+	Display_Name = Mount_Point.substr(1, Mount_Point.size() - 1);
+	Backup_Name = Display_Name;
+	if (Fstab_File_System == "emmc")
+		Backup_Method = DD;
+	else if (Fstab_File_System == "mtd")
+		Backup_Method = FLASH_UTILS;
+	else
+		LOGI("Unhandled file system '%s' on image '%s'\n", Fstab_File_System.c_str(), Display_Name.c_str());
+	if (Find_Partition_Size()) {
+		Used = Size;
+		Backup_Size = Size;
 	} else {
-		return 1;
+		if (Display_Error)
+			LOGE("Unable to find parition size for '%s'\n", Block_Device.c_str());
+		else
+			LOGI("Unable to find parition size for '%s'\n", Block_Device.c_str());
 	}
 }
 
-bool TWPartition::UnMount(bool Display_Error) {
-	LOGI("STUB TWPartition::Mount, Display_Error: %i\n", Display_Error);
-	if (Is_Mounted()) {
-		return 1;
+void TWPartition::Find_Real_Block_Device(string& Block, bool Display_Error) {
+	char device[512], realDevice[512];
+
+	strcpy(device, Block.c_str());
+	memset(realDevice, 0, sizeof(realDevice));
+	while (readlink(device, realDevice, sizeof(realDevice)) > 0)
+	{
+		strcpy(device, realDevice);
+		memset(realDevice, 0, sizeof(realDevice));
+	}
+
+	if (device[0] != '/') {
+		if (Display_Error)
+			LOGE("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
+		else
+			LOGI("Invalid symlink path '%s' found on block device '%s'\n", device, Block.c_str());
+		return;
 	} else {
-		return 1;
+		Block = device;
+		return;
+	}
+}
+
+bool TWPartition::Get_Size_Via_df(string Path, bool Display_Error) {
+	FILE* fp;
+	char command[255], line[512];
+	int include_block = 1;
+	unsigned int min_len;
+
+	if (!Mount(Display_Error))
+		return false;
+
+	min_len = Block_Device.size() + 2;
+	sprintf(command, "df %s", Path.c_str());
+	fp = __popen(command, "r");
+	if (fp == NULL)
+		return false;
+
+	while (fgets(line, sizeof(line), fp) != NULL)
+	{
+		unsigned long blocks, used, available;
+		char device[64];
+		char tmpString[64];
+
+		if (strncmp(line, "Filesystem", 10) == 0)
+			continue;
+		if (strlen(line) < min_len) {
+			include_block = 0;
+			continue;
+		}
+		if (include_block) {
+			sscanf(line, "%s %lu %lu %lu", device, &blocks, &used, &available);
+		} else {
+			// The device block string is so long that the df information is on the next line
+			int space_count = 0;
+			while (tmpString[space_count] == 32)
+				space_count++;
+			sscanf(line + space_count, "%lu %lu %lu", &blocks, &used, &available);
+		}
+
+		// Adjust block size to byte size
+		Size = blocks * 1024ULL;
+		Used = used * 1024ULL;
+		Free = available * 1024ULL;
+		Backup_Size = Used;
+	}
+	fclose(fp);
+	return true;
+}
+
+unsigned long long TWPartition::Get_Size_Via_du(string Path, bool Display_Error) {
+	char cmd[512];
+    sprintf(cmd, "du -sk %s | awk '{ print $1 }'", Path.c_str());
+
+    FILE *fp;
+    fp = __popen(cmd, "r");
+    
+    char str[512];
+    fgets(str, sizeof(str), fp);
+    __pclose(fp);
+
+    unsigned long long dusize = atol(str);
+    dusize *= 1024ULL;
+
+    return dusize;
+}
+
+bool TWPartition::Find_Partition_Size(void) {
+	FILE* fp;
+	char line[512];
+	string tmpdevice;
+
+	// In this case, we'll first get the partitions we care about (with labels)
+	fp = fopen("/proc/partitions", "rt");
+	if (fp == NULL)
+		return false;
+
+	while (fgets(line, sizeof(line), fp) != NULL)
+	{
+		unsigned long major, minor, blocks;
+		char device[512];
+		char tmpString[64];
+
+		if (strlen(line) < 7 || line[0] == 'm')     continue;
+		sscanf(line + 1, "%lu %lu %lu %s", &major, &minor, &blocks, device);
+
+		tmpdevice = "/dev/block/";
+		tmpdevice += device;
+		if (tmpdevice == Block_Device || tmpdevice == Alternate_Block_Device) {
+			// Adjust block size to byte size
+			Size = blocks * 1024ULL;
+			fclose(fp);
+			return true;
+		}
+	}
+	fclose(fp);
+	return false;
+}
+
+bool TWPartition::Path_Exists(string Path) {
+	// Check to see if the Path exists
+	struct statfs st;
+
+	if (statfs(Path.c_str(), &st) != 0)
+		return false;
+	else
+		return true;
+}
+
+void TWPartition::Flip_Block_Device(void) {
+	string temp;
+
+	temp = Alternate_Block_Device;
+	Block_Device = Alternate_Block_Device;
+	Alternate_Block_Device = temp;
+}
+
+bool TWPartition::Is_Mounted(void) {
+	if (!Can_Be_Mounted)
+		return false;
+
+	struct stat st1, st2;
+	string test_path;
+
+	// Check to see if the mount point directory exists
+	test_path = Mount_Point + "/.";
+	if (stat(test_path.c_str(), &st1) != 0)  return false;
+
+	// Check to see if the directory above the mount point exists
+	test_path = Mount_Point + "/../.";
+	if (stat(test_path.c_str(), &st2) != 0)  return false;
+
+	// Compare the device IDs -- if they match then we're (probably) using tmpfs instead of an actual device
+	int ret = (st1.st_dev != st2.st_dev) ? true : false;
+
+	return ret;
+}
+
+bool TWPartition::Mount(bool Display_Error) {
+	if (Is_Mounted()) {
+		return true;
+	} else if (!Can_Be_Mounted) {
+		return false;
+	}
+	if (Is_Decrypted) {
+		if (mount(Decrypted_Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
+			Check_FS_Type();
+			if (mount(Decrypted_Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
+				if (Display_Error)
+					LOGE("Unable to mount decrypted block device '%s' to '%s'\n", Decrypted_Block_Device.c_str(), Mount_Point.c_str());
+				else
+					LOGI("Unable to mount decrypted block device '%s' to '%s'\n", Decrypted_Block_Device.c_str(), Mount_Point.c_str());
+				return false;
+			} else
+				return true;
+		} else
+			return true;
+	}
+	if (mount(Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
+		Check_FS_Type();
+		if (mount(Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
+			if (Alternate_Block_Device != "" && Path_Exists(Alternate_Block_Device)) {
+				Flip_Block_Device();
+				Check_FS_Type();
+				if (mount(Block_Device.c_str(), Mount_Point.c_str(), Current_File_System.c_str(), 0, NULL) != 0) {
+					if (Display_Error)
+						LOGE("Unable to mount '%s'\n", Mount_Point.c_str());
+					else
+						LOGI("Unable to mount '%s'\n", Mount_Point.c_str());
+					return false;
+				} else
+					return true;
+			} else
+				return false;
+		} else
+			return true;
+	}
+	return true;
+}
+
+bool TWPartition::UnMount(bool Display_Error) {
+	if (Is_Mounted()) {
+		int never_unmount_system;
+
+		DataManager::GetValue(TW_DONT_UNMOUNT_SYSTEM, never_unmount_system);
+		if (never_unmount_system == 1 && Mount_Point == "/system")
+			return true; // Never unmount system if you're not supposed to unmount it
+
+		if (umount(Mount_Point.c_str()) != 0) {
+			if (Display_Error)
+				LOGE("Unable to unmount '%s'\n", Mount_Point.c_str());
+			else
+				LOGI("Unable to unmount '%s'\n", Mount_Point.c_str());
+			return false;
+		} else
+			return true;
+	} else {
+		return true;
 	}
 }
 
@@ -128,7 +544,70 @@
 }
 
 void TWPartition::Check_FS_Type() {
-	LOGI("STUB TWPartition::Check_FS_Type\n");
+	FILE *fp;
+	string blkCommand;
+	char blkOutput[255];
+	char* blk;
+	char* arg;
+	char* ptr;
+
+	if (Fstab_File_System == "yaffs2" || Fstab_File_System == "mtd")
+		return; // Running blkid on some mtd devices causes a massive crash
+
+	if (Is_Decrypted)
+		blkCommand = "blkid " + Decrypted_Block_Device;
+	else
+		blkCommand = "blkid " + Block_Device;
+	fp = __popen(blkCommand.c_str(), "r");
+	while (fgets(blkOutput, sizeof(blkOutput), fp) != NULL)
+	{
+		blk = blkOutput;
+		ptr = blkOutput;
+		while (*ptr > 32 && *ptr != ':')        ptr++;
+		if (*ptr == 0)                          continue;
+		*ptr = 0;
+
+		// Increment by two, but verify that we don't hit a NULL
+		ptr++;
+		if (*ptr != 0)      ptr++;
+
+		// Now, find the TYPE field
+		while (1)
+		{
+			arg = ptr;
+			while (*ptr > 32)       ptr++;
+			if (*ptr != 0)
+			{
+				*ptr = 0;
+				ptr++;
+			}
+
+			if (strlen(arg) > 6)
+			{
+				if (memcmp(arg, "TYPE=\"", 6) == 0)  break;
+			}
+
+			if (*ptr == 0)
+			{
+				arg = NULL;
+				break;
+			}
+		}
+
+		if (arg && strlen(arg) > 7)
+		{
+			arg += 6;   // Skip the TYPE=" portion
+			arg[strlen(arg)-1] = '\0';  // Drop the tail quote
+		}
+		else
+			continue;
+
+        if (strcmp(Current_File_System.c_str(), arg) != 0) {
+			LOGI("'%s' was '%s' now set to '%s'\n", Mount_Point.c_str(), Current_File_System.c_str(), arg);
+			Current_File_System = arg;
+		}
+	}
+	__pclose(fp);
 	return;
 }
 
@@ -191,3 +670,22 @@
 	LOGI("STUB TWPartition::Restore_Flash_Image, backup_folder: '%s'\n", restore_folder.c_str());
 	return 1;
 }
+
+bool TWPartition::Update_Size(bool Display_Error) {
+	if (!Can_Be_Mounted)
+		return false;
+
+	if (!Get_Size_Via_df(Mount_Point, Display_Error))
+		return false;
+	if (Has_Data_Media) {
+		if (Mount(Display_Error)) {
+			unsigned long long data_used, data_media_used, actual_data;
+			data_used = Get_Size_Via_du("/data/", Display_Error);
+			data_media_used = Get_Size_Via_du("/data/media/", Display_Error);
+			actual_data = data_used - data_media_used;
+			Backup_Size = actual_data;
+		} else
+			return false;
+	}
+	return true;
+}
\ No newline at end of file
diff --git a/partitionmanager.cpp b/partitionmanager.cpp
index d0821bb..2e50641 100644
--- a/partitionmanager.cpp
+++ b/partitionmanager.cpp
@@ -26,28 +26,139 @@
 #include <sys/stat.h>
 #include <sys/vfs.h>
 #include <unistd.h>
+#include <vector>
 
 #include "variables.h"
 #include "common.h"
 #include "partitions.hpp"
+#include "data.hpp"
+
+#ifdef TW_INCLUDE_CRYPTO
+	#ifdef TW_INCLUDE_JB_CRYPTO
+		#include "crypto/jb/cryptfs.h"
+	#else
+		#include "crypto/ics/cryptfs.h"
+	#endif
+	#include "cutils/properties.h"
+#endif
 
 int TWPartitionManager::Process_Fstab(string Fstab_Filename, bool Display_Error) {
-	LOGI("STUB TWPartitionManager::Process_Fstab, Fstab_Filename: '%s', Display_Error: %i\n", Fstab_Filename.c_str(), Display_Error);
-	return 1;
+	FILE *fstabFile;
+	char fstab_line[MAX_FSTAB_LINE_LENGTH];
+
+	fstabFile = fopen(Fstab_Filename.c_str(), "rt");
+	if (fstabFile == NULL) {
+		LOGE("Critical Error: Unable to open fstab at '%s'.\n", Fstab_Filename.c_str());
+		return false;
+	}
+
+	while (fgets(fstab_line, sizeof(fstab_line), fstabFile) != NULL) {
+		if (fstab_line[0] != '/')
+			continue;
+
+		TWPartition* partition = new TWPartition();
+		string line(fstab_line);
+		if (partition->Process_Fstab_Line(line, Display_Error)) {
+			Partitions.push_back(partition);
+		} else {
+			delete partition;
+		}
+	}
+	fclose(fstabFile);
+	if (!Write_Fstab()) {
+		if (Display_Error)
+			LOGE("Error creating fstab\n");
+		else
+			LOGI("Error creating fstab\n");
+	}
+	return true;
+}
+
+int TWPartitionManager::Write_Fstab(void) {
+	FILE *fp;
+	std::vector<TWPartition*>::iterator iter;
+	string Line;
+
+	fp = fopen("/etc/fstab", "w");
+	if (fp == NULL) {
+        LOGI("Can not open /etc/fstab.\n");
+		return false;
+	}
+    for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		if ((*iter)->Can_Be_Mounted && (*iter)->Is_Present) {
+			if ((*iter)->Is_Decrypted)
+				Line = (*iter)->Decrypted_Block_Device + " " + (*iter)->Mount_Point + " " + (*iter)->Current_File_System + " rw\n";
+			else
+				Line = (*iter)->Block_Device + " " + (*iter)->Mount_Point + " " + (*iter)->Current_File_System + " rw\n";
+			fputs(Line.c_str(), fp);
+		}
+	}
+	fclose(fp);
+	return true;
 }
 
 int TWPartitionManager::Mount_By_Path(string Path, bool Display_Error) {
-	LOGI("STUB TWPartitionManager::Mount_By_Path, Path: '%s', Display_Error: %i\n", Path.c_str(), Display_Error);
-	return 1;
+	std::vector<TWPartition*>::iterator iter;
+	int ret = false;
+	bool found = false;
+	string Local_Path = Path;
+
+	// Make sure that we have a leading slash
+	if (Local_Path.substr(0, 1) != "/")
+		Local_Path = "/" + Local_Path;
+
+	// Trim the path to get the root path only
+	size_t position = Local_Path.find("/", 2);
+	if (position != string::npos) {
+		Local_Path.resize(position);
+	}
+
+	// Iterate through all partitions
+	for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		if ((*iter)->Mount_Point == Local_Path) {
+			ret = (*iter)->Mount(Display_Error);
+			found = true;
+		} else if ((*iter)->Is_SubPartition && (*iter)->SubPartition_Of == Local_Path)
+			(*iter)->Mount(Display_Error);
+	}
+	if (found) {
+		return ret;
+	} else if (Display_Error) {
+		LOGE("Unable to find partition for path '%s'\n", Local_Path.c_str());
+	} else {
+		LOGI("Unable to find partition for path '%s'\n", Local_Path.c_str());
+	}
+	return false;
 }
 
 int TWPartitionManager::Mount_By_Block(string Block, bool Display_Error) {
-	LOGI("STUB TWPartitionManager::Mount_By_Block, Block: '%s', Display_Error: %i\n", Block.c_str(), Display_Error);
-	return 1;
+	std::vector<TWPartition*>::iterator iter;
+
+	for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		if ((*iter)->Block_Device == Block)
+			return (*iter)->Mount(Display_Error);
+		else if ((*iter)->Alternate_Block_Device == Block)
+			return (*iter)->Mount(Display_Error);
+	}
+	if (Display_Error)
+		LOGE("Unable to find partition for block '%s'\n", Block.c_str());
+	else
+		LOGI("Unable to find partition for block '%s'\n", Block.c_str());
+	return false;
 }
 
 int TWPartitionManager::Mount_By_Name(string Name, bool Display_Error) {
-	LOGI("STUB TWPartitionManager::Mount_By_Path, Name: '%s', Display_Error: %i\n", Name.c_str(), Display_Error);
+	std::vector<TWPartition*>::iterator iter;
+
+	for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		if ((*iter)->Display_Name == Name)
+			return (*iter)->Mount(Display_Error);
+	}
+	if (Display_Error)
+		LOGE("Unable to find partition for name '%s'\n", Name.c_str());
+	else
+		LOGI("Unable to find partition for name '%s'\n", Name.c_str());
+	return false;
 	return 1;
 }
 
@@ -81,20 +192,33 @@
 	return 1;
 }
 
-int TWPartitionManager::Mount_Current_Storage(void) {
-	LOGI("STUB TWPartitionManager::Mount_Current_Storage\n");
-	return 1;
+int TWPartitionManager::Mount_Current_Storage(bool Display_Error) {
+	return Mount_By_Path(DataManager::GetCurrentStoragePath(), Display_Error);
 }
 
-/**TWPartition TWPartitionManager::Find_Partition_By_Path(string Path) {
-	LOGI("STUB TWPartitionManager::Find_Partition_By_Path, Path: '%s'\n", Path.c_str());
+int TWPartitionManager::Mount_Settings_Storage(bool Display_Error) {
+	return Mount_By_Path(DataManager::GetSettingsStoragePath(), Display_Error);
+}
+
+TWPartition* TWPartitionManager::Find_Partition_By_Path(string Path) {
+	std::vector<TWPartition*>::iterator iter;
+
+	for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		if ((*iter)->Mount_Point == Path)
+			return (*iter);
+	}
 	return NULL;
 }
 
-*TWPartition TWPartitionManager::Find_Partition_By_Block(string Block) {
+TWPartition* TWPartitionManager::Find_Partition_By_Block(string Block) {
 	LOGI("STUB TWPartitionManager::Find_Partition_By_Block, Block: '%s'\n", Block.c_str());
 	return NULL;
-}*/
+}
+
+TWPartition* TWPartitionManager::Find_Partition_By_Name(string Name) {
+	LOGI("STUB TWPartitionManager::Find_Partition_By_Name, Name: '%s'\n", Name.c_str());
+	return NULL;
+}
 
 int TWPartitionManager::Run_Backup(string Backup_Name) {
 	LOGI("STUB TWPartitionManager::Run_Backup, Backup_Name: '%s'\n", Backup_Name.c_str());
@@ -137,11 +261,61 @@
 }
 
 void TWPartitionManager::Update_System_Details(void) {
-	LOGI("STUB TWPartitionManager::Update_System_Details\n");
+	std::vector<TWPartition*>::iterator iter;
+
+	LOGI("Updating system details...\n");
+	for (iter = Partitions.begin(); iter != Partitions.end(); iter++) {
+		(*iter)->Check_FS_Type();
+		(*iter)->Update_Size(false);
+	}
+	if (!Write_Fstab())
+		LOGE("Error creating fstab\n");
 	return;
 }
 
 int TWPartitionManager::Decrypt_Device(string Password) {
-	LOGI("STUB TWPartitionManager::Decrypt_Device, Password: '%s'\n", Password.c_str());
+#ifdef TW_INCLUDE_CRYPTO
+	int ret_val, password_len;
+	char crypto_blkdev[255], cPassword[255];
+	size_t result;
+
+	property_set("ro.crypto.state", "encrypted");
+#ifdef TW_INCLUDE_JB_CRYPTO
+	// No extra flags needed
+#else
+	property_set("ro.crypto.fs_type", CRYPTO_FS_TYPE);
+	property_set("ro.crypto.fs_real_blkdev", CRYPTO_REAL_BLKDEV);
+	property_set("ro.crypto.fs_mnt_point", CRYPTO_MNT_POINT);
+	property_set("ro.crypto.fs_options", CRYPTO_FS_OPTIONS);
+	property_set("ro.crypto.fs_flags", CRYPTO_FS_FLAGS);
+	property_set("ro.crypto.keyfile.userdata", CRYPTO_KEY_LOC);
+#endif
+	strcpy(cPassword, Password.c_str());
+	if (cryptfs_check_passwd(cPassword) != 0) {
+		LOGE("Failed to decrypt data.\n");
+		return -1;
+	}
+	property_get("ro.crypto.fs_crypto_blkdev", crypto_blkdev, "error");
+	if (strcmp(crypto_blkdev, "error") == 0) {
+		LOGE("Error retrieving decrypted data block device.\n");
+	} else {
+		TWPartition* dat = Find_Partition_By_Path("/data");
+		if (dat != NULL) {
+			DataManager::SetValue(TW_DATA_BLK_DEVICE, dat->Block_Device);
+			DataManager::SetValue(TW_IS_DECRYPTED, 1);
+			dat->Is_Decrypted = true;
+			dat->Decrypted_Block_Device = crypto_blkdev;
+			LOGI("Data successfully decrypted, new block device: '%s'\n", crypto_blkdev);
+			// Sleep for a bit so that the device will be ready
+			sleep(1);
+			Update_System_Details();
+		} else
+			LOGE("Unable to locate data partition.\n");
+	}
+	return 0;
+#else
+	LOGE("No crypto support was compiled into this build.\n");
+	return -1;
+#endif
 	return 1;
 }
\ No newline at end of file
diff --git a/partitions.hpp b/partitions.hpp
index 2915e73..13ce028 100644
--- a/partitions.hpp
+++ b/partitions.hpp
@@ -25,7 +25,8 @@
 
 #include <vector>
 #include <string>
-#include <map>
+
+#define MAX_FSTAB_LINE_LENGTH 2048
 
 using namespace std;
 
@@ -54,10 +55,11 @@
 	static string Backup_Method_By_Name();                                    // Returns a string of the backup method for human readable output
 	virtual bool Decrypt(string Password);                                    // Decrypts the partition, return 0 for failure and -1 for success
 	virtual bool Wipe_Encryption();                                           // Ignores wipe commands for /data/media devices and formats the original block device
-	void Check_FS_Type();                                                     // Checks the fs type using blkid, does not do anything on MTD / yaffs2 because this crashes on some devices
+	virtual void Check_FS_Type();                                             // Checks the fs type using blkid, does not do anything on MTD / yaffs2 because this crashes on some devices
+	virtual bool Update_Size(bool Display_Error);                             // Updates size information
 
 protected:
-	bool Process_Fstab_Line(string Line);                                     // Processes a fstab line
+	bool Process_Fstab_Line(string Line, bool Display_Error);                 // Processes a fstab line
 
 protected:
 	bool Can_Be_Mounted;                                                      // Indicates that the partition can be mounted
@@ -65,7 +67,7 @@
 	bool Wipe_During_Factory_Reset;                                           // Indicates that this partition is wiped during a factory reset
 	bool Wipe_Available_in_GUI;                                               // Inidcates that the wipe can be user initiated in the GUI system
 	bool Is_SubPartition;                                                     // Indicates that this partition is a sub-partition of another partition (e.g. datadata is a sub-partition of data)
-	string SubPartition_Of;                                                   // Indicates which partition is the parent partition of this partition (e.g. data is the parent partition of datadata)
+	string SubPartition_Of;                                                   // Indicates which partition is the parent partition of this partition (e.g. /data is the parent partition of /datadata)
 	string Symlink_Path;                                                      // Symlink path (e.g. /data/media)
 	string Symlink_Mount_Point;                                               // /sdcard could be the symlink mount point for /data/media
 	string Mount_Point;                                                       // Mount point for this partition (e.g. /system or /data)
@@ -85,14 +87,24 @@
 	string Display_Name;                                                      // Display name for the GUI
 	string Backup_Name;                                                       // Backup name -- used for backup filenames
 	Backup_Method_enum Backup_Method;                                         // Method used for backup
-	bool Has_Data_Media;                                                       // Indicates presence of /data/media, may affect wiping and backup methods
-	bool Is_Storage;                                                           // Indicates if this partition is used for storage for backup, restore, and installing zips
-	string Storage_Path;                                                       // Indicates the path to the storage -- root indicates mount point, media/ indicates e.g. /data/media
-	string Current_File_System;                                                // Current file system
-	string Fstab_File_System;                                                  // File system from the recovery.fstab
-	int Format_Block_Size;                                                     // Block size for formatting
+	bool Has_Data_Media;                                                      // Indicates presence of /data/media, may affect wiping and backup methods
+	bool Is_Storage;                                                          // Indicates if this partition is used for storage for backup, restore, and installing zips
+	string Storage_Path;                                                      // Indicates the path to the storage -- root indicates mount point, media/ indicates e.g. /data/media
+	string Current_File_System;                                               // Current file system
+	string Fstab_File_System;                                                 // File system from the recovery.fstab
+	int Format_Block_Size;                                                    // Block size for formatting
 
 private:
+	bool Is_File_System(string File_System);                                  // Checks to see if the file system given is considered a file system
+	bool Is_Image(string File_System);                                        // Checks to see if the file system given is considered an image
+	void Setup_File_System(bool Display_Error);                               // Sets defaults for a file system partition
+	void Setup_Image(bool Display_Error);                                     // Sets defaults for an image partition
+	bool Path_Exists(string Path);                                            // Checks to see if the Path exists in the file system
+	void Find_Real_Block_Device(string& Block_Device, bool Display_Error);    // Checks the block device given and follows symlinks until it gets to the real block device
+	bool Find_Partition_Size();                                               // Finds the partition size from /proc/partitions
+	bool Get_Size_Via_df(string Path, bool Display_Error);                    // Uses df to get sizes
+	unsigned long long Get_Size_Via_du(string Path, bool Display_Error);      // Uses du to get sizes
+	void Flip_Block_Device();                                                 // Flips the Block_Device and Alternate_Block_Device
 	bool Wipe_EXT23();                                                        // Formats as ext3 or ext2
 	bool Wipe_EXT4();                                                         // Formats using ext4, uses make_ext4fs when present
 	bool Wipe_FAT();                                                          // Formats as FAT except that mkdosfs from busybox usually fails so oftentimes this is actually a rm -rf wipe
@@ -112,32 +124,41 @@
 class TWPartitionManager
 {
 public:
-	static int Process_Fstab(string Fstab_Filename, bool Display_Error);     // Parses the fstab and populates the partitions
-	static int Mount_By_Path(string Path, bool Display_Error);               // Mounts partition based on path (e.g. /system)
-	static int Mount_By_Block(string Block, bool Display_Error);             // Mounts partition based on block device (e.g. /dev/block/mmcblk1p1)
-	static int Mount_By_Name(string Name, bool Display_Error);               // Mounts partition based on display name (e.g. System)
-	static int UnMount_By_Path(string Path, bool Display_Error);             // Unmounts partition based on path
-	static int UnMount_By_Block(string Block, bool Display_Error);           // Unmounts partition based on block device
-	static int UnMount_By_Name(string Name, bool Display_Error);             // Unmounts partition based on display name
-	static int Is_Mounted_By_Path(string Path);                              // Checks if partition is mounted based on path
-	static int Is_Mounted_By_Block(string Block);                            // Checks if partition is mounted based on block device
-	static int Is_Mounted_By_Name(string Name);                              // Checks if partition is mounted based on display name
-	static int Mount_Current_Storage();                                      // Mounts the current storage location
-	//static *TWPartition Find_Partition_By_Path(string Path);                  // Returns a pointer to a partition based on path
-	//static *TWPartition Find_Partition_By_Block(string Block);                // Returns a pointer to a partition based on block device
-	static int Run_Backup(string Backup_Name);                               // Initiates a backup in the current storage
-	static int Run_Restore(string Restore_Name);                             // Restores a backup
-	static void Set_Restore_Files(string Restore_Name);                             // Used to gather a list of available backup partitions for the user to select for a restore
-	static int Wipe_By_Path(string Path);                                    // Wipes a partition based on path
-	static int Wipe_By_Block(string Block);                                  // Wipes a partition based on block device
-	static int Wipe_By_Name(string Name);                                    // Wipes a partition based on display name
-	static int Factory_Reset();                                              // Performs a factory reset
-	static void Refresh_Sizes();                                             // Refreshes size data of partitions
-	static void Update_System_Details();                                     // Updates fstab, file systems, sizes, etc.
-	static int Decrypt_Device(string Password);                              // Attempt to decrypt any encrypted partitions
+	TWPartitionManager() {}
+	virtual ~TWPartitionManager() {}
+
+public:
+	virtual int Process_Fstab(string Fstab_Filename, bool Display_Error);     // Parses the fstab and populates the partitions
+	virtual int Write_Fstab();                                                // Creates /etc/fstab file that's used by the command line for mount commands
+	virtual int Mount_By_Path(string Path, bool Display_Error);               // Mounts partition based on path (e.g. /system)
+	virtual int Mount_By_Block(string Block, bool Display_Error);             // Mounts partition based on block device (e.g. /dev/block/mmcblk1p1)
+	virtual int Mount_By_Name(string Name, bool Display_Error);               // Mounts partition based on display name (e.g. System)
+	virtual int UnMount_By_Path(string Path, bool Display_Error);             // Unmounts partition based on path
+	virtual int UnMount_By_Block(string Block, bool Display_Error);           // Unmounts partition based on block device
+	virtual int UnMount_By_Name(string Name, bool Display_Error);             // Unmounts partition based on display name
+	virtual int Is_Mounted_By_Path(string Path);                              // Checks if partition is mounted based on path
+	virtual int Is_Mounted_By_Block(string Block);                            // Checks if partition is mounted based on block device
+	virtual int Is_Mounted_By_Name(string Name);                              // Checks if partition is mounted based on display name
+	virtual int Mount_Current_Storage(bool Display_Error);                    // Mounts the current storage location
+	virtual int Mount_Settings_Storage(bool Display_Error);                   // Mounts the settings file storage location (usually internal)
+	TWPartition* Find_Partition_By_Path(string Path);                         // Returns a pointer to a partition based on path
+	TWPartition* Find_Partition_By_Block(string Block);                       // Returns a pointer to a partition based on block device
+	TWPartition* Find_Partition_By_Name(string Block);                        // Returns a pointer to a partition based on name
+	virtual int Run_Backup(string Backup_Name);                               // Initiates a backup in the current storage
+	virtual int Run_Restore(string Restore_Name);                             // Restores a backup
+	virtual void Set_Restore_Files(string Restore_Name);                      // Used to gather a list of available backup partitions for the user to select for a restore
+	virtual int Wipe_By_Path(string Path);                                    // Wipes a partition based on path
+	virtual int Wipe_By_Block(string Block);                                  // Wipes a partition based on block device
+	virtual int Wipe_By_Name(string Name);                                    // Wipes a partition based on display name
+	virtual int Factory_Reset();                                              // Performs a factory reset
+	virtual void Refresh_Sizes();                                             // Refreshes size data of partitions
+	virtual void Update_System_Details();                                     // Updates fstab, file systems, sizes, etc.
+	virtual int Decrypt_Device(string Password);                              // Attempt to decrypt any encrypted partitions
 
 private:
 	std::vector<TWPartition*> Partitions;
 };
 
-#endif // __TWRP_Partition_Manager
\ No newline at end of file
+extern TWPartitionManager PartitionManager;
+
+#endif // __TWRP_Partition_Manager
diff --git a/recovery.cpp b/recovery.cpp
index 2c77271..319cdc7 100644
--- a/recovery.cpp
+++ b/recovery.cpp
@@ -52,10 +52,8 @@
 }
 #include "partitions.hpp"
 
-int gui_init(void);
-int gui_loadResources(void);
-int gui_start(void);
-int gui_console_only(void);
+TWPartitionManager PartitionManager;
+char device_id[64];
 
 struct selabel_handle *sehandle;
 
@@ -810,7 +808,7 @@
 	printf("=> Linking mtab\n");
 	__system("ln -s /proc/mounts /etc/mtab"); // And link mtab for mke2fs
 	printf("=> Processing recovery.fstab\n");
-	if (TWPartitionManager::Process_Fstab("/etc/recovery.fstab", 1)) {
+	if (!PartitionManager.Process_Fstab("/etc/recovery.fstab", 1)) {
 		LOGE("Failing out of recovery due to problem with recovery.fstab.\n");
 		//return -1;
 	}
@@ -905,7 +903,7 @@
         if (status != INSTALL_SUCCESS) ui->Print("Installation aborted.\n");
     } else if (wipe_data) {
 		gui_console_only();
-		if (TWPartitionManager::Factory_Reset()) status = INSTALL_ERROR;
+		if (PartitionManager.Factory_Reset()) status = INSTALL_ERROR;
         //if (device->WipeData()) status = INSTALL_ERROR;
         //if (erase_volume("/data")) status = INSTALL_ERROR;
         //if (wipe_cache && erase_volume("/cache")) status = INSTALL_ERROR;
