diff --git a/twbootloader.cpp b/twbootloader.cpp
index 826ceca..d0e49e0 100644
--- a/twbootloader.cpp
+++ b/twbootloader.cpp
@@ -33,33 +33,35 @@
 static int set_bootloader_message_block(const struct bootloader_message *in, const TWPartition* Partition);
 
 int get_bootloader_message(struct bootloader_message *out) {
-    TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
-    if (Part == NULL) {
-      //LOGE("Cannot load volume /misc!\n");
-      return -1;
-    }
-    if (Part->Current_File_System == "mtd") {
-        return get_bootloader_message_mtd(out, Part);
-    } else if (Part->Current_File_System == "emmc") {
-        return get_bootloader_message_block(out, Part);
-    }
-    LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
-    return -1;
+	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
+	if (Part == NULL) {
+	  //LOGE("Cannot load volume /misc!\n");
+	  return -1;
+	}
+
+	if (Part->Current_File_System == "mtd")
+		return get_bootloader_message_mtd(out, Part);
+	else if (Part->Current_File_System == "emmc")
+		return get_bootloader_message_block(out, Part);
+
+	LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
+	return -1;
 }
 
 int set_bootloader_message(const struct bootloader_message *in) {
-    TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
-    if (Part == NULL) {
-      //LOGE("Cannot load volume /misc!\n");
-      return -1;
-    }
-    if (Part->Current_File_System == "mtd") {
-        return set_bootloader_message_mtd(in, Part);
-    } else if (Part->Current_File_System == "emmc") {
-        return set_bootloader_message_block(in, Part);
-    }
-    LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
-    return -1;
+	TWPartition* Part = PartitionManager.Find_Partition_By_Path("/misc");
+	if (Part == NULL) {
+	  //LOGE("Cannot load volume /misc!\n");
+	  return -1;
+	}
+
+	if (Part->Current_File_System == "mtd")
+		return set_bootloader_message_mtd(in, Part);
+	else if (Part->Current_File_System == "emmc")
+		return set_bootloader_message_block(in, Part);
+
+	LOGE("unknown misc partition fs_type \"%s\"\n", Part->Current_File_System.c_str());
+	return -1;
 }
 
 // ------------------------------
@@ -71,134 +73,141 @@
 
 static int get_bootloader_message_mtd(struct bootloader_message *out,
                                       const TWPartition* Partition) {
-    size_t write_size;
-    mtd_scan_partitions();
-    const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
-    if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
-        LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
-        return -1;
-    }
+	size_t write_size;
+	mtd_scan_partitions();
+	const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
+	if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
+		LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
+		return -1;
+	}
 
-    MtdReadContext *read = mtd_read_partition(part);
-    if (read == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdReadContext *read = mtd_read_partition(part);
+	if (read == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    const ssize_t size = write_size * MISC_PAGES;
-    char data[size];
-    ssize_t r = mtd_read_data(read, data, size);
-    if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-    mtd_read_close(read);
-    if (r != size) return -1;
+	const ssize_t size = write_size * MISC_PAGES;
+	char data[size];
+	ssize_t r = mtd_read_data(read, data, size);
+	if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+	mtd_read_close(read);
+	if (r != size) return -1;
 
-    memcpy(out, &data[write_size * MISC_COMMAND_PAGE], sizeof(*out));
-    return 0;
+	memcpy(out, &data[write_size * MISC_COMMAND_PAGE], sizeof(*out));
+	return 0;
 }
 static int set_bootloader_message_mtd(const struct bootloader_message *in,
                                       const TWPartition* Partition) {
-    size_t write_size;
-    mtd_scan_partitions();
-    const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
-    if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
-        LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
-        return -1;
-    }
+	size_t write_size;
+	mtd_scan_partitions();
+	const MtdPartition *part = mtd_find_partition_by_name(Partition->MTD_Name.c_str());
+	if (part == NULL || mtd_partition_info(part, NULL, NULL, &write_size)) {
+		LOGE("Can't find %s\n", Partition->MTD_Name.c_str());
+		return -1;
+	}
 
-    MtdReadContext *read = mtd_read_partition(part);
-    if (read == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdReadContext *read = mtd_read_partition(part);
+	if (read == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    ssize_t size = write_size * MISC_PAGES;
-    char data[size];
-    ssize_t r = mtd_read_data(read, data, size);
-    if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-    mtd_read_close(read);
-    if (r != size) return -1;
+	ssize_t size = write_size * MISC_PAGES;
+	char data[size];
+	ssize_t r = mtd_read_data(read, data, size);
+	if (r != size) LOGE("Can't read %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+	mtd_read_close(read);
+	if (r != size) return -1;
 
-    memcpy(&data[write_size * MISC_COMMAND_PAGE], in, sizeof(*in));
+	memcpy(&data[write_size * MISC_COMMAND_PAGE], in, sizeof(*in));
 
-    MtdWriteContext *write = mtd_write_partition(part);
-    if (write == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
-    if (mtd_write_data(write, data, size) != size) {
-        LOGE("Can't write %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        mtd_write_close(write);
-        return -1;
-    }
-    if (mtd_write_close(write)) {
-        LOGE("Can't finish %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
-        return -1;
-    }
+	MtdWriteContext *write = mtd_write_partition(part);
+	if (write == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
+	if (mtd_write_data(write, data, size) != size) {
+		LOGE("Can't write %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		mtd_write_close(write);
+		return -1;
+	}
+	if (mtd_write_close(write)) {
+		LOGE("Can't finish %s\n(%s)\n", Partition->MTD_Name.c_str(), strerror(errno));
+		return -1;
+	}
 
-    LOGI("Set boot command \"%s\"\n", in->command[0] != 255 ? in->command : "");
-    return 0;
+	LOGI("Set boot command \"%s\"\n", in->command[0] != 255 ? in->command : "");
+	return 0;
 }
 
-
 // ------------------------------------
 // for misc partitions on block devices
 // ------------------------------------
 
 static void wait_for_device(const char* fn) {
-    int tries = 0;
-    int ret;
-    struct stat buf;
-    do {
-        ++tries;
-        ret = stat(fn, &buf);
-        if (ret) {
-            printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
-            sleep(1);
-        }
-    } while (ret && tries < 10);
-    if (ret) {
-        printf("failed to stat %s\n", fn);
-    }
+	int tries = 0;
+	int ret;
+	struct stat buf;
+
+	do {
+		++tries;
+		ret = stat(fn, &buf);
+		if (ret) {
+			printf("stat %s try %d: %s\n", fn, tries, strerror(errno));
+			sleep(1);
+		}
+	} while (ret && tries < 10);
+
+	if (ret)
+		printf("failed to stat %s\n", fn);
 }
 
 static int get_bootloader_message_block(struct bootloader_message *out,
                                         const TWPartition* Partition) {
-    wait_for_device(Partition->Actual_Block_Device.c_str());
-    FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "rb");
-    if (f == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    struct bootloader_message temp;
-    int count = fread(&temp, sizeof(temp), 1, f);
-    if (count != 1) {
-        LOGE("Failed reading %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    if (fclose(f) != 0) {
-        LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    memcpy(out, &temp, sizeof(temp));
-    return 0;
+	wait_for_device(Partition->Actual_Block_Device.c_str());
+
+	FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "rb");
+	if (f == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	struct bootloader_message temp;
+	int count = fread(&temp, sizeof(temp), 1, f);
+	if (count != 1) {
+		LOGE("Failed reading %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	if (fclose(f) != 0) {
+		LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	memcpy(out, &temp, sizeof(temp));
+	return 0;
 }
 
 static int set_bootloader_message_block(const struct bootloader_message *in,
                                         const TWPartition* Partition) {
-    wait_for_device(Partition->Actual_Block_Device.c_str());
-    FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "wb");
-    if (f == NULL) {
-        LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    int count = fwrite(in, sizeof(*in), 1, f);
-    if (count != 1) {
-        LOGE("Failed writing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    if (fclose(f) != 0) {
-        LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
-        return -1;
-    }
-    return 0;
+	wait_for_device(Partition->Actual_Block_Device.c_str());
+
+	FILE* f = fopen(Partition->Actual_Block_Device.c_str(), "wb");
+	if (f == NULL) {
+		LOGE("Can't open %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	int count = fwrite(in, sizeof(*in), 1, f);
+	if (count != 1) {
+		LOGE("Failed writing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+
+	if (fclose(f) != 0) {
+		LOGE("Failed closing %s\n(%s)\n", Partition->Actual_Block_Device.c_str(), strerror(errno));
+		return -1;
+	}
+	return 0;
 }
