all: Reformat C and Python source code with tools/codeformat.py.

This is run with uncrustify 0.70.1, and black 19.10b0.
diff --git a/py/argcheck.c b/py/argcheck.c
index 3b3f9ee..87e13bc 100644
--- a/py/argcheck.c
+++ b/py/argcheck.c
@@ -113,7 +113,7 @@
         }
     }
     if (pos_found < n_pos) {
-        extra_positional:
+    extra_positional:
         if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
             mp_arg_error_terse_mismatch();
         } else {
diff --git a/py/asmarm.c b/py/asmarm.c
index 59c661c..72b37f7 100644
--- a/py/asmarm.c
+++ b/py/asmarm.c
@@ -40,20 +40,20 @@
 
 void asm_arm_end_pass(asm_arm_t *as) {
     if (as->base.pass == MP_ASM_PASS_EMIT) {
-#if defined(__linux__) && defined(__GNUC__)
+        #if defined(__linux__) && defined(__GNUC__)
         char *start = mp_asm_base_get_code(&as->base);
         char *end = start + mp_asm_base_get_code_size(&as->base);
         __builtin___clear_cache(start, end);
-#elif defined(__arm__)
+        #elif defined(__arm__)
         // flush I- and D-cache
-        asm volatile(
-                "0:"
-                "mrc p15, 0, r15, c7, c10, 3\n"
-                "bne 0b\n"
-                "mov r0, #0\n"
-                "mcr p15, 0, r0, c7, c7, 0\n"
-                : : : "r0", "cc");
-#endif
+        asm volatile (
+            "0:"
+            "mrc p15, 0, r15, c7, c10, 3\n"
+            "bne 0b\n"
+            "mov r0, #0\n"
+            "mcr p15, 0, r0, c7, c7, 0\n"
+            : : : "r0", "cc");
+        #endif
     }
 }
 
@@ -61,7 +61,7 @@
 STATIC void emit(asm_arm_t *as, uint op) {
     uint8_t *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
     if (c != NULL) {
-        *(uint32_t*)c = op;
+        *(uint32_t *)c = op;
     }
 }
 
diff --git a/py/asmbase.c b/py/asmbase.c
index ab861da..344e03e 100644
--- a/py/asmbase.c
+++ b/py/asmbase.c
@@ -51,7 +51,7 @@
         memset(as->label_offsets, -1, as->max_num_labels * sizeof(size_t));
     } else {
         // allocating executable RAM is platform specific
-        MP_PLAT_ALLOC_EXEC(as->code_offset, (void**)&as->code_base, &as->code_size);
+        MP_PLAT_ALLOC_EXEC(as->code_offset, (void **)&as->code_base, &as->code_size);
         assert(as->code_base != NULL);
     }
     as->pass = pass;
@@ -84,12 +84,12 @@
 }
 
 // align must be a multiple of 2
-void mp_asm_base_align(mp_asm_base_t* as, unsigned int align) {
+void mp_asm_base_align(mp_asm_base_t *as, unsigned int align) {
     as->code_offset = (as->code_offset + align - 1) & (~(align - 1));
 }
 
 // this function assumes a little endian machine
-void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val) {
+void mp_asm_base_data(mp_asm_base_t *as, unsigned int bytesize, uintptr_t val) {
     uint8_t *c = mp_asm_base_get_cur_to_write_bytes(as, bytesize);
     if (c != NULL) {
         for (unsigned int i = 0; i < bytesize; i++) {
diff --git a/py/asmbase.h b/py/asmbase.h
index b5e2593..24c3af8 100644
--- a/py/asmbase.h
+++ b/py/asmbase.h
@@ -47,8 +47,8 @@
 void mp_asm_base_start_pass(mp_asm_base_t *as, int pass);
 uint8_t *mp_asm_base_get_cur_to_write_bytes(mp_asm_base_t *as, size_t num_bytes_to_write);
 void mp_asm_base_label_assign(mp_asm_base_t *as, size_t label);
-void mp_asm_base_align(mp_asm_base_t* as, unsigned int align);
-void mp_asm_base_data(mp_asm_base_t* as, unsigned int bytesize, uintptr_t val);
+void mp_asm_base_align(mp_asm_base_t *as, unsigned int align);
+void mp_asm_base_data(mp_asm_base_t *as, unsigned int bytesize, uintptr_t val);
 
 static inline size_t mp_asm_base_get_code_pos(mp_asm_base_t *as) {
     return as->code_offset;
diff --git a/py/asmthumb.c b/py/asmthumb.c
index 68fb8f2..bb10935 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -377,7 +377,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         asm_thumb_op32(as, OP_BW_HI(rel), OP_BW_LO(rel));
     }
 }
@@ -396,7 +396,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         asm_thumb_op32(as, OP_BCC_W_HI(cond, rel), OP_BCC_W_LO(rel));
     }
 }
diff --git a/py/asmthumb.h b/py/asmthumb.h
index c21c23f..6d0ee4b 100644
--- a/py/asmthumb.h
+++ b/py/asmthumb.h
@@ -95,8 +95,9 @@
 void asm_thumb_op16(asm_thumb_t *as, uint op);
 void asm_thumb_op32(asm_thumb_t *as, uint op1, uint op2);
 
-static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask)
-    { asm_thumb_op16(as, ASM_THUMB_OP_IT | (cc << 4) | mask); }
+static inline void asm_thumb_it_cc(asm_thumb_t *as, uint cc, uint mask) {
+    asm_thumb_op16(as, ASM_THUMB_OP_IT | (cc << 4) | mask);
+}
 
 // FORMAT 1: move shifted register
 
@@ -129,14 +130,18 @@
     asm_thumb_op16(as, ASM_THUMB_FORMAT_2_ENCODE(op, rlo_dest, rlo_src, src_b));
 }
 
-static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b)
-    { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); }
-static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src)
-    { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); }
-static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b)
-    { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b); }
-static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src)
-    { asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src); }
+static inline void asm_thumb_add_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) {
+    asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b);
+}
+static inline void asm_thumb_add_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) {
+    asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_ADD | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src);
+}
+static inline void asm_thumb_sub_rlo_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, uint rlo_src_b) {
+    asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_REG_OPERAND, rlo_dest, rlo_src_a, rlo_src_b);
+}
+static inline void asm_thumb_sub_rlo_rlo_i3(asm_thumb_t *as, uint rlo_dest, uint rlo_src_a, int i3_src) {
+    asm_thumb_format_2(as, ASM_THUMB_FORMAT_2_SUB | ASM_THUMB_FORMAT_2_IMM_OPERAND, rlo_dest, rlo_src_a, i3_src);
+}
 
 // FORMAT 3: move/compare/add/subtract immediate
 // These instructions all do zero extension of the i8 value
@@ -153,10 +158,18 @@
     asm_thumb_op16(as, ASM_THUMB_FORMAT_3_ENCODE(op, rlo, i8));
 }
 
-static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_MOV, rlo, i8); }
-static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_CMP, rlo, i8); }
-static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_ADD, rlo, i8); }
-static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) { asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_SUB, rlo, i8); }
+static inline void asm_thumb_mov_rlo_i8(asm_thumb_t *as, uint rlo, int i8) {
+    asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_MOV, rlo, i8);
+}
+static inline void asm_thumb_cmp_rlo_i8(asm_thumb_t *as, uint rlo, int i8) {
+    asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_CMP, rlo, i8);
+}
+static inline void asm_thumb_add_rlo_i8(asm_thumb_t *as, uint rlo, int i8) {
+    asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_ADD, rlo, i8);
+}
+static inline void asm_thumb_sub_rlo_i8(asm_thumb_t *as, uint rlo, int i8) {
+    asm_thumb_format_3(as, ASM_THUMB_FORMAT_3_SUB, rlo, i8);
+}
 
 // FORMAT 4: ALU operations
 
@@ -179,7 +192,9 @@
 
 void asm_thumb_format_4(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_src);
 
-static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) { asm_thumb_format_4(as, ASM_THUMB_FORMAT_4_CMP, rlo_dest, rlo_src); }
+static inline void asm_thumb_cmp_rlo_rlo(asm_thumb_t *as, uint rlo_dest, uint rlo_src) {
+    asm_thumb_format_4(as, ASM_THUMB_FORMAT_4_CMP, rlo_dest, rlo_src);
+}
 
 // FORMAT 5: hi register operations (add, cmp, mov, bx)
 // For add/cmp/mov, at least one of the args must be a high register
@@ -219,21 +234,28 @@
 #define ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset) \
     ((op) | (((offset) << 6) & 0x07c0) | ((rlo_base) << 3) | (rlo_dest))
 
-static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset)
-    { asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset)); }
+static inline void asm_thumb_format_9_10(asm_thumb_t *as, uint op, uint rlo_dest, uint rlo_base, uint offset) {
+    asm_thumb_op16(as, ASM_THUMB_FORMAT_9_10_ENCODE(op, rlo_dest, rlo_base, offset));
+}
 
-static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_src, rlo_base, word_offset); }
-static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER, rlo_src, rlo_base, byte_offset); }
-static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_STRH, rlo_src, rlo_base, byte_offset); }
-static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_dest, rlo_base, word_offset); }
-static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER , rlo_dest, rlo_base, byte_offset); }
-static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset)
-    { asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_LDRH, rlo_dest, rlo_base, byte_offset); }
+static inline void asm_thumb_str_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint word_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_src, rlo_base, word_offset);
+}
+static inline void asm_thumb_strb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_STR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER, rlo_src, rlo_base, byte_offset);
+}
+static inline void asm_thumb_strh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_src, uint rlo_base, uint byte_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_STRH, rlo_src, rlo_base, byte_offset);
+}
+static inline void asm_thumb_ldr_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint word_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER, rlo_dest, rlo_base, word_offset);
+}
+static inline void asm_thumb_ldrb_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_BYTE_TRANSFER, rlo_dest, rlo_base, byte_offset);
+}
+static inline void asm_thumb_ldrh_rlo_rlo_i5(asm_thumb_t *as, uint rlo_dest, uint rlo_base, uint byte_offset) {
+    asm_thumb_format_9_10(as, ASM_THUMB_FORMAT_10_LDRH, rlo_dest, rlo_base, byte_offset);
+}
 
 // TODO convert these to above format style
 
diff --git a/py/asmx64.c b/py/asmx64.c
index b18703a..f52b028 100644
--- a/py/asmx64.c
+++ b/py/asmx64.c
@@ -123,14 +123,14 @@
 }
 
 STATIC void asm_x64_write_byte_1(asm_x64_t *as, byte b1) {
-    byte* c = asm_x64_get_cur_to_write_bytes(as, 1);
+    byte *c = asm_x64_get_cur_to_write_bytes(as, 1);
     if (c != NULL) {
         c[0] = b1;
     }
 }
 
 STATIC void asm_x64_write_byte_2(asm_x64_t *as, byte b1, byte b2) {
-    byte* c = asm_x64_get_cur_to_write_bytes(as, 2);
+    byte *c = asm_x64_get_cur_to_write_bytes(as, 2);
     if (c != NULL) {
         c[0] = b1;
         c[1] = b2;
@@ -138,7 +138,7 @@
 }
 
 STATIC void asm_x64_write_byte_3(asm_x64_t *as, byte b1, byte b2, byte b3) {
-    byte* c = asm_x64_get_cur_to_write_bytes(as, 3);
+    byte *c = asm_x64_get_cur_to_write_bytes(as, 3);
     if (c != NULL) {
         c[0] = b1;
         c[1] = b2;
@@ -147,7 +147,7 @@
 }
 
 STATIC void asm_x64_write_word32(asm_x64_t *as, int w32) {
-    byte* c = asm_x64_get_cur_to_write_bytes(as, 4);
+    byte *c = asm_x64_get_cur_to_write_bytes(as, 4);
     if (c != NULL) {
         c[0] = IMM32_L0(w32);
         c[1] = IMM32_L1(w32);
@@ -157,7 +157,7 @@
 }
 
 STATIC void asm_x64_write_word64(asm_x64_t *as, int64_t w64) {
-    byte* c = asm_x64_get_cur_to_write_bytes(as, 8);
+    byte *c = asm_x64_get_cur_to_write_bytes(as, 8);
     if (c != NULL) {
         c[0] = IMM32_L0(w64);
         c[1] = IMM32_L1(w64);
@@ -378,11 +378,11 @@
     asm_x64_generic_r64_r64(as, dest_r64, src_r64, OPCODE_XOR_R64_TO_RM64);
 }
 
-void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64) {
+void asm_x64_shl_r64_cl(asm_x64_t *as, int dest_r64) {
     asm_x64_generic_r64_r64(as, dest_r64, 4, OPCODE_SHL_RM64_CL);
 }
 
-void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64) {
+void asm_x64_sar_r64_cl(asm_x64_t *as, int dest_r64) {
     asm_x64_generic_r64_r64(as, dest_r64, 7, OPCODE_SAR_RM64_CL);
 }
 
@@ -500,7 +500,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         rel -= 5;
         asm_x64_write_byte_1(as, OPCODE_JMP_REL32);
         asm_x64_write_word32(as, rel);
@@ -522,7 +522,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         rel -= 6;
         asm_x64_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type);
         asm_x64_write_word32(as, rel);
diff --git a/py/asmx64.h b/py/asmx64.h
index d3761b7..28b1bd2 100644
--- a/py/asmx64.h
+++ b/py/asmx64.h
@@ -79,12 +79,12 @@
     (void)as;
 }
 
-void asm_x64_nop(asm_x64_t* as);
-void asm_x64_push_r64(asm_x64_t* as, int src_r64);
-void asm_x64_pop_r64(asm_x64_t* as, int dest_r64);
-void asm_x64_mov_r64_r64(asm_x64_t* as, int dest_r64, int src_r64);
+void asm_x64_nop(asm_x64_t *as);
+void asm_x64_push_r64(asm_x64_t *as, int src_r64);
+void asm_x64_pop_r64(asm_x64_t *as, int dest_r64);
+void asm_x64_mov_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
 size_t asm_x64_mov_i32_to_r64(asm_x64_t *as, int src_i32, int dest_r64);
-void asm_x64_mov_i64_to_r64(asm_x64_t* as, int64_t src_i64, int dest_r64);
+void asm_x64_mov_i64_to_r64(asm_x64_t *as, int64_t src_i64, int dest_r64);
 void asm_x64_mov_i64_to_r64_optimised(asm_x64_t *as, int64_t src_i64, int dest_r64);
 void asm_x64_mov_r8_to_mem8(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp);
 void asm_x64_mov_r16_to_mem16(asm_x64_t *as, int src_r64, int dest_r64, int dest_disp);
@@ -97,25 +97,25 @@
 void asm_x64_and_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
 void asm_x64_or_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
 void asm_x64_xor_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
-void asm_x64_shl_r64_cl(asm_x64_t* as, int dest_r64);
-void asm_x64_sar_r64_cl(asm_x64_t* as, int dest_r64);
-void asm_x64_add_r64_r64(asm_x64_t* as, int dest_r64, int src_r64);
-void asm_x64_sub_r64_r64(asm_x64_t* as, int dest_r64, int src_r64);
-void asm_x64_mul_r64_r64(asm_x64_t* as, int dest_r64, int src_r64);
-void asm_x64_cmp_r64_with_r64(asm_x64_t* as, int src_r64_a, int src_r64_b);
-void asm_x64_test_r8_with_r8(asm_x64_t* as, int src_r64_a, int src_r64_b);
+void asm_x64_shl_r64_cl(asm_x64_t *as, int dest_r64);
+void asm_x64_sar_r64_cl(asm_x64_t *as, int dest_r64);
+void asm_x64_add_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
+void asm_x64_sub_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
+void asm_x64_mul_r64_r64(asm_x64_t *as, int dest_r64, int src_r64);
+void asm_x64_cmp_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64_b);
+void asm_x64_test_r8_with_r8(asm_x64_t *as, int src_r64_a, int src_r64_b);
 void asm_x64_test_r64_with_r64(asm_x64_t *as, int src_r64_a, int src_r64_b);
-void asm_x64_setcc_r8(asm_x64_t* as, int jcc_type, int dest_r8);
+void asm_x64_setcc_r8(asm_x64_t *as, int jcc_type, int dest_r8);
 void asm_x64_jmp_reg(asm_x64_t *as, int src_r64);
-void asm_x64_jmp_label(asm_x64_t* as, mp_uint_t label);
-void asm_x64_jcc_label(asm_x64_t* as, int jcc_type, mp_uint_t label);
-void asm_x64_entry(asm_x64_t* as, int num_locals);
-void asm_x64_exit(asm_x64_t* as);
-void asm_x64_mov_local_to_r64(asm_x64_t* as, int src_local_num, int dest_r64);
-void asm_x64_mov_r64_to_local(asm_x64_t* as, int src_r64, int dest_local_num);
-void asm_x64_mov_local_addr_to_r64(asm_x64_t* as, int local_num, int dest_r64);
+void asm_x64_jmp_label(asm_x64_t *as, mp_uint_t label);
+void asm_x64_jcc_label(asm_x64_t *as, int jcc_type, mp_uint_t label);
+void asm_x64_entry(asm_x64_t *as, int num_locals);
+void asm_x64_exit(asm_x64_t *as);
+void asm_x64_mov_local_to_r64(asm_x64_t *as, int src_local_num, int dest_r64);
+void asm_x64_mov_r64_to_local(asm_x64_t *as, int src_r64, int dest_local_num);
+void asm_x64_mov_local_addr_to_r64(asm_x64_t *as, int local_num, int dest_r64);
 void asm_x64_mov_reg_pcrel(asm_x64_t *as, int dest_r64, mp_uint_t label);
-void asm_x64_call_ind(asm_x64_t* as, size_t fun_id, int temp_r32);
+void asm_x64_call_ind(asm_x64_t *as, size_t fun_id, int temp_r32);
 
 // Holds a pointer to mp_fun_table
 #define ASM_X64_REG_FUN_TABLE ASM_X64_REG_RBP
diff --git a/py/asmx86.c b/py/asmx86.c
index e69d06d..4a8be3f 100644
--- a/py/asmx86.c
+++ b/py/asmx86.c
@@ -103,14 +103,14 @@
 #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
 
 STATIC void asm_x86_write_byte_1(asm_x86_t *as, byte b1) {
-    byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1);
+    byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 1);
     if (c != NULL) {
         c[0] = b1;
     }
 }
 
 STATIC void asm_x86_write_byte_2(asm_x86_t *as, byte b1, byte b2) {
-    byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2);
+    byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 2);
     if (c != NULL) {
         c[0] = b1;
         c[1] = b2;
@@ -118,7 +118,7 @@
 }
 
 STATIC void asm_x86_write_byte_3(asm_x86_t *as, byte b1, byte b2, byte b3) {
-    byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3);
+    byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 3);
     if (c != NULL) {
         c[0] = b1;
         c[1] = b2;
@@ -127,7 +127,7 @@
 }
 
 STATIC void asm_x86_write_word32(asm_x86_t *as, int w32) {
-    byte* c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
+    byte *c = mp_asm_base_get_cur_to_write_bytes(&as->base, 4);
     if (c != NULL) {
         c[0] = IMM32_L0(w32);
         c[1] = IMM32_L1(w32);
@@ -255,11 +255,11 @@
     asm_x86_generic_r32_r32(as, dest_r32, src_r32, OPCODE_XOR_R32_TO_RM32);
 }
 
-void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32) {
+void asm_x86_shl_r32_cl(asm_x86_t *as, int dest_r32) {
     asm_x86_generic_r32_r32(as, dest_r32, 4, OPCODE_SHL_RM32_CL);
 }
 
-void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32) {
+void asm_x86_sar_r32_cl(asm_x86_t *as, int dest_r32) {
     asm_x86_generic_r32_r32(as, dest_r32, 7, OPCODE_SAR_RM32_CL);
 }
 
@@ -368,7 +368,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         rel -= 5;
         asm_x86_write_byte_1(as, OPCODE_JMP_REL32);
         asm_x86_write_word32(as, rel);
@@ -390,7 +390,7 @@
         }
     } else {
         // is a forwards jump, so need to assume it's large
-        large_jump:
+    large_jump:
         rel -= 6;
         asm_x86_write_byte_2(as, OPCODE_JCC_REL32_A, OPCODE_JCC_REL32_B | jcc_type);
         asm_x86_write_word32(as, rel);
@@ -488,8 +488,7 @@
     asm_x86_push_disp(as, ASM_X86_REG_ESP, asm_x86_local_offset_from_esp(as, local_num));
 }
 
-void asm_x86_push_local_addr(asm_x86_t *as, int local_num, int temp_r32)
-{
+void asm_x86_push_local_addr(asm_x86_t *as, int local_num, int temp_r32) {
     asm_x86_mov_r32_r32(as, temp_r32, ASM_X86_REG_ESP);
     asm_x86_add_i32_to_r32(as, asm_x86_local_offset_from_esp(as, local_num), temp_r32);
     asm_x86_push_r32(as, temp_r32);
diff --git a/py/asmx86.h b/py/asmx86.h
index abcea18..4855cd7 100644
--- a/py/asmx86.h
+++ b/py/asmx86.h
@@ -81,7 +81,7 @@
     (void)as;
 }
 
-void asm_x86_mov_r32_r32(asm_x86_t* as, int dest_r32, int src_r32);
+void asm_x86_mov_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
 size_t asm_x86_mov_i32_to_r32(asm_x86_t *as, int32_t src_i32, int dest_r32);
 void asm_x86_mov_r8_to_mem8(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp);
 void asm_x86_mov_r16_to_mem16(asm_x86_t *as, int src_r32, int dest_r32, int dest_disp);
@@ -92,26 +92,26 @@
 void asm_x86_and_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
 void asm_x86_or_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
 void asm_x86_xor_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
-void asm_x86_shl_r32_cl(asm_x86_t* as, int dest_r32);
-void asm_x86_sar_r32_cl(asm_x86_t* as, int dest_r32);
-void asm_x86_add_r32_r32(asm_x86_t* as, int dest_r32, int src_r32);
-void asm_x86_sub_r32_r32(asm_x86_t* as, int dest_r32, int src_r32);
-void asm_x86_mul_r32_r32(asm_x86_t* as, int dest_r32, int src_r32);
-void asm_x86_cmp_r32_with_r32(asm_x86_t* as, int src_r32_a, int src_r32_b);
-void asm_x86_test_r8_with_r8(asm_x86_t* as, int src_r32_a, int src_r32_b);
-void asm_x86_test_r32_with_r32(asm_x86_t* as, int src_r32_a, int src_r32_b);
-void asm_x86_setcc_r8(asm_x86_t* as, mp_uint_t jcc_type, int dest_r8);
+void asm_x86_shl_r32_cl(asm_x86_t *as, int dest_r32);
+void asm_x86_sar_r32_cl(asm_x86_t *as, int dest_r32);
+void asm_x86_add_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
+void asm_x86_sub_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
+void asm_x86_mul_r32_r32(asm_x86_t *as, int dest_r32, int src_r32);
+void asm_x86_cmp_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_b);
+void asm_x86_test_r8_with_r8(asm_x86_t *as, int src_r32_a, int src_r32_b);
+void asm_x86_test_r32_with_r32(asm_x86_t *as, int src_r32_a, int src_r32_b);
+void asm_x86_setcc_r8(asm_x86_t *as, mp_uint_t jcc_type, int dest_r8);
 void asm_x86_jmp_reg(asm_x86_t *as, int src_r86);
-void asm_x86_jmp_label(asm_x86_t* as, mp_uint_t label);
-void asm_x86_jcc_label(asm_x86_t* as, mp_uint_t jcc_type, mp_uint_t label);
-void asm_x86_entry(asm_x86_t* as, int num_locals);
-void asm_x86_exit(asm_x86_t* as);
+void asm_x86_jmp_label(asm_x86_t *as, mp_uint_t label);
+void asm_x86_jcc_label(asm_x86_t *as, mp_uint_t jcc_type, mp_uint_t label);
+void asm_x86_entry(asm_x86_t *as, int num_locals);
+void asm_x86_exit(asm_x86_t *as);
 void asm_x86_mov_arg_to_r32(asm_x86_t *as, int src_arg_num, int dest_r32);
-void asm_x86_mov_local_to_r32(asm_x86_t* as, int src_local_num, int dest_r32);
-void asm_x86_mov_r32_to_local(asm_x86_t* as, int src_r32, int dest_local_num);
-void asm_x86_mov_local_addr_to_r32(asm_x86_t* as, int local_num, int dest_r32);
+void asm_x86_mov_local_to_r32(asm_x86_t *as, int src_local_num, int dest_r32);
+void asm_x86_mov_r32_to_local(asm_x86_t *as, int src_r32, int dest_local_num);
+void asm_x86_mov_local_addr_to_r32(asm_x86_t *as, int local_num, int dest_r32);
 void asm_x86_mov_reg_pcrel(asm_x86_t *as, int dest_r64, mp_uint_t label);
-void asm_x86_call_ind(asm_x86_t* as, size_t fun_id, mp_uint_t n_args, int temp_r32);
+void asm_x86_call_ind(asm_x86_t *as, size_t fun_id, mp_uint_t n_args, int temp_r32);
 
 // Holds a pointer to mp_fun_table
 #define ASM_X86_REG_FUN_TABLE ASM_X86_REG_EBP
diff --git a/py/asmxtensa.c b/py/asmxtensa.c
index 32e5e95..0956d50 100644
--- a/py/asmxtensa.c
+++ b/py/asmxtensa.c
@@ -65,7 +65,7 @@
     // jump over the constants
     asm_xtensa_op_j(as, as->num_const * WORD_SIZE + 4 - 4);
     mp_asm_base_get_cur_to_write_bytes(&as->base, 1); // padding/alignment byte
-    as->const_table = (uint32_t*)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4);
+    as->const_table = (uint32_t *)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4);
 
     // adjust the stack-pointer to store a0, a12, a13, a14, a15 and locals, 16-byte aligned
     as->stack_adjust = (((ASM_XTENSA_NUM_REGS_SAVED + num_locals) * WORD_SIZE) + 15) & ~15;
@@ -105,7 +105,7 @@
     // jump over the constants
     asm_xtensa_op_j(as, as->num_const * WORD_SIZE + 4 - 4);
     mp_asm_base_get_cur_to_write_bytes(&as->base, 1); // padding/alignment byte
-    as->const_table = (uint32_t*)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4);
+    as->const_table = (uint32_t *)mp_asm_base_get_cur_to_write_bytes(&as->base, as->num_const * 4);
 
     as->stack_adjust = 32 + ((((ASM_XTENSA_NUM_REGS_SAVED_WIN + num_locals) * WORD_SIZE) + 15) & ~15);
     asm_xtensa_op_entry(as, ASM_XTENSA_REG_A1, as->stack_adjust);
@@ -173,7 +173,7 @@
 
 size_t asm_xtensa_mov_reg_i32(asm_xtensa_t *as, uint reg_dest, uint32_t i32) {
     // load the constant
-    uint32_t const_table_offset = (uint8_t*)as->const_table - as->base.code_base;
+    uint32_t const_table_offset = (uint8_t *)as->const_table - as->base.code_base;
     size_t loc = const_table_offset + as->cur_const * WORD_SIZE;
     asm_xtensa_op_l32r(as, reg_dest, as->base.code_offset, loc);
     // store the constant in the table
diff --git a/py/bc.c b/py/bc.c
index 417ac3c..34b9284 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -75,21 +75,21 @@
 #endif
 
 STATIC NORETURN void fun_pos_args_mismatch(mp_obj_fun_bc_t *f, size_t expected, size_t given) {
-#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
+    #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE
     // generic message, used also for other argument issues
     (void)f;
     (void)expected;
     (void)given;
     mp_arg_error_terse_mismatch();
-#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
+    #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_NORMAL
     (void)f;
     mp_raise_msg_varg(&mp_type_TypeError,
         "function takes %d positional arguments but %d were given", expected, given);
-#elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
+    #elif MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
     mp_raise_msg_varg(&mp_type_TypeError,
         "%q() takes %d positional arguments but %d were given",
         mp_obj_fun_get_name(MP_OBJ_FROM_PTR(f)), expected, given);
-#endif
+    #endif
 }
 
 #if DEBUG_PRINT
@@ -195,7 +195,7 @@
         }
 
         // get pointer to arg_names array
-        const mp_obj_t *arg_names = (const mp_obj_t*)self->const_table;
+        const mp_obj_t *arg_names = (const mp_obj_t *)self->const_table;
 
         for (size_t i = 0; i < n_kw; i++) {
             // the keys in kwargs are expected to be qstr objects
@@ -220,7 +220,7 @@
                 }
             }
             mp_obj_dict_store(dict, kwargs[2 * i], kwargs[2 * i + 1]);
-continue2:;
+        continue2:;
         }
 
         DEBUG_printf("Args with kws flattened: ");
@@ -252,7 +252,7 @@
             if (code_state->state[n_state - 1 - n_pos_args - i] == MP_OBJ_NULL) {
                 mp_map_elem_t *elem = NULL;
                 if ((scope_flags & MP_SCOPE_FLAG_DEFKWARGS) != 0) {
-                    elem = mp_map_lookup(&((mp_obj_dict_t*)MP_OBJ_TO_PTR(self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP);
+                    elem = mp_map_lookup(&((mp_obj_dict_t *)MP_OBJ_TO_PTR(self->extra_args[n_def_pos_args]))->map, arg_names[n_pos_args + i], MP_MAP_LOOKUP);
                 }
                 if (elem != NULL) {
                     code_state->state[n_state - 1 - n_pos_args - i] = elem->value;
diff --git a/py/bc.h b/py/bc.h
index a96d17a..65af407 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -72,94 +72,94 @@
 //  constN          : obj
 
 #define MP_BC_PRELUDE_SIG_ENCODE(S, E, scope, out_byte, out_env) \
-do {                                                            \
-    /*// Get values to store in prelude */                      \
-    size_t F = scope->scope_flags & MP_SCOPE_FLAG_ALL_SIG;      \
-    size_t A = scope->num_pos_args;                             \
-    size_t K = scope->num_kwonly_args;                          \
-    size_t D = scope->num_def_pos_args;                         \
+    do {                                                            \
+        /*// Get values to store in prelude */                      \
+        size_t F = scope->scope_flags & MP_SCOPE_FLAG_ALL_SIG;      \
+        size_t A = scope->num_pos_args;                             \
+        size_t K = scope->num_kwonly_args;                          \
+        size_t D = scope->num_def_pos_args;                         \
                                                                 \
-    /* Adjust S to shrink range, to compress better */          \
-    S -= 1;                                                     \
+        /* Adjust S to shrink range, to compress better */          \
+        S -= 1;                                                     \
                                                                 \
-    /* Encode prelude */                                        \
-    /* xSSSSEAA */                                              \
-    uint8_t z = (S & 0xf) << 3 | (E & 1) << 2 | (A & 3);        \
-    S >>= 4;                                                    \
-    E >>= 1;                                                    \
-    A >>= 2;                                                    \
-    while (S | E | F | A | K | D) {                             \
-        out_byte(out_env, 0x80 | z);                            \
-        /* xFSSKAED */                                          \
-        z = (F & 1) << 6 | (S & 3) << 4 | (K & 1) << 3          \
-            | (A & 1) << 2 | (E & 1) << 1 | (D & 1);            \
-        S >>= 2;                                                \
-        E >>= 1;                                                \
-        F >>= 1;                                                \
-        A >>= 1;                                                \
-        K >>= 1;                                                \
-        D >>= 1;                                                \
-    }                                                           \
-    out_byte(out_env, z);                                       \
-} while (0)
+        /* Encode prelude */                                        \
+        /* xSSSSEAA */                                              \
+        uint8_t z = (S & 0xf) << 3 | (E & 1) << 2 | (A & 3);        \
+        S >>= 4;                                                    \
+        E >>= 1;                                                    \
+        A >>= 2;                                                    \
+        while (S | E | F | A | K | D) {                             \
+            out_byte(out_env, 0x80 | z);                            \
+            /* xFSSKAED */                                          \
+            z = (F & 1) << 6 | (S & 3) << 4 | (K & 1) << 3          \
+                | (A & 1) << 2 | (E & 1) << 1 | (D & 1);            \
+            S >>= 2;                                                \
+            E >>= 1;                                                \
+            F >>= 1;                                                \
+            A >>= 1;                                                \
+            K >>= 1;                                                \
+            D >>= 1;                                                \
+        }                                                           \
+        out_byte(out_env, z);                                       \
+    } while (0)
 
 #define MP_BC_PRELUDE_SIG_DECODE_INTO(ip, S, E, F, A, K, D)     \
-do {                                                            \
-    uint8_t z = *(ip)++;                                        \
-    /* xSSSSEAA */                                              \
-    S = (z >> 3) & 0xf;                                         \
-    E = (z >> 2) & 0x1;                                         \
-    F = 0;                                                      \
-    A = z & 0x3;                                                \
-    K = 0;                                                      \
-    D = 0;                                                      \
-    for (unsigned n = 0; z & 0x80; ++n) {                       \
-        z = *(ip)++;                                            \
-        /* xFSSKAED */                                          \
-        S |= (z & 0x30) << (2 * n);                             \
-        E |= (z & 0x02) << n;                                   \
-        F |= ((z & 0x40) >> 6) << n;                            \
-        A |= (z & 0x4) << n;                                    \
-        K |= ((z & 0x08) >> 3) << n;                            \
-        D |= (z & 0x1) << n;                                    \
-    }                                                           \
-    S += 1;                                                     \
-} while (0)
+    do {                                                            \
+        uint8_t z = *(ip)++;                                        \
+        /* xSSSSEAA */                                              \
+        S = (z >> 3) & 0xf;                                         \
+        E = (z >> 2) & 0x1;                                         \
+        F = 0;                                                      \
+        A = z & 0x3;                                                \
+        K = 0;                                                      \
+        D = 0;                                                      \
+        for (unsigned n = 0; z & 0x80; ++n) {                       \
+            z = *(ip)++;                                            \
+            /* xFSSKAED */                                          \
+            S |= (z & 0x30) << (2 * n);                             \
+            E |= (z & 0x02) << n;                                   \
+            F |= ((z & 0x40) >> 6) << n;                            \
+            A |= (z & 0x4) << n;                                    \
+            K |= ((z & 0x08) >> 3) << n;                            \
+            D |= (z & 0x1) << n;                                    \
+        }                                                           \
+        S += 1;                                                     \
+    } while (0)
 
 #define MP_BC_PRELUDE_SIG_DECODE(ip) \
     size_t n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args; \
     MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_pos_args)
 
 #define MP_BC_PRELUDE_SIZE_ENCODE(I, C, out_byte, out_env)      \
-do {                                                            \
-    /* Encode bit-wise as: xIIIIIIC */                          \
-    uint8_t z = 0;                                              \
-    do {                                                        \
-        z = (I & 0x3f) << 1 | (C & 1);                          \
-        C >>= 1;                                                \
-        I >>= 6;                                                \
-        if (C | I) {                                            \
-            z |= 0x80;                                          \
-        }                                                       \
-        out_byte(out_env, z);                                   \
-    } while (C | I);                                            \
-} while (0)
+    do {                                                            \
+        /* Encode bit-wise as: xIIIIIIC */                          \
+        uint8_t z = 0;                                              \
+        do {                                                        \
+            z = (I & 0x3f) << 1 | (C & 1);                          \
+            C >>= 1;                                                \
+            I >>= 6;                                                \
+            if (C | I) {                                            \
+                z |= 0x80;                                          \
+            }                                                       \
+            out_byte(out_env, z);                                   \
+        } while (C | I);                                            \
+    } while (0)
 
 #define MP_BC_PRELUDE_SIZE_DECODE_INTO(ip, I, C)                \
-do {                                                            \
-    uint8_t z;                                                  \
-    C = 0;                                                      \
-    I = 0;                                                      \
-    for (unsigned n = 0;; ++n) {                                \
-        z = *(ip)++;                                            \
-        /* xIIIIIIC */                                          \
-        C |= (z & 1) << n;                                      \
-        I |= ((z & 0x7e) >> 1) << (6 * n);                      \
-        if (!(z & 0x80)) {                                      \
-            break;                                              \
-        }                                                       \
-    }                                                           \
-} while (0)
+    do {                                                            \
+        uint8_t z;                                                  \
+        C = 0;                                                      \
+        I = 0;                                                      \
+        for (unsigned n = 0;; ++n) {                                \
+            z = *(ip)++;                                            \
+            /* xIIIIIIC */                                          \
+            C |= (z & 1) << n;                                      \
+            I |= ((z & 0x7e) >> 1) << (6 * n);                      \
+            if (!(z & 0x80)) {                                      \
+                break;                                              \
+            }                                                       \
+        }                                                           \
+    } while (0)
 
 #define MP_BC_PRELUDE_SIZE_DECODE(ip) \
     size_t n_info, n_cell; \
@@ -232,10 +232,10 @@
 #define mp_bytecode_print_inst(code, const_table) mp_bytecode_print2(code, 1, const_table)
 
 // Helper macros to access pointer with least significant bits holding flags
-#define MP_TAGPTR_PTR(x) ((void*)((uintptr_t)(x) & ~((uintptr_t)3)))
+#define MP_TAGPTR_PTR(x) ((void *)((uintptr_t)(x) & ~((uintptr_t)3)))
 #define MP_TAGPTR_TAG0(x) ((uintptr_t)(x) & 1)
 #define MP_TAGPTR_TAG1(x) ((uintptr_t)(x) & 2)
-#define MP_TAGPTR_MAKE(ptr, tag) ((void*)((uintptr_t)(ptr) | (tag)))
+#define MP_TAGPTR_MAKE(ptr, tag) ((void *)((uintptr_t)(ptr) | (tag)))
 
 #if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_PERSISTENT_CODE_SAVE
 
diff --git a/py/binary.c b/py/binary.c
index a8907bf..faa4135 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -46,24 +46,40 @@
     size_t size = 0;
     int align = 1;
     switch (struct_type) {
-        case '<': case '>':
+        case '<':
+        case '>':
             switch (val_type) {
-                case 'b': case 'B':
-                    size = 1; break;
-                case 'h': case 'H':
-                    size = 2; break;
-                case 'i': case 'I':
-                    size = 4; break;
-                case 'l': case 'L':
-                    size = 4; break;
-                case 'q': case 'Q':
-                    size = 8; break;
-                case 'P': case 'O': case 'S':
-                    size = sizeof(void*); break;
+                case 'b':
+                case 'B':
+                    size = 1;
+                    break;
+                case 'h':
+                case 'H':
+                    size = 2;
+                    break;
+                case 'i':
+                case 'I':
+                    size = 4;
+                    break;
+                case 'l':
+                case 'L':
+                    size = 4;
+                    break;
+                case 'q':
+                case 'Q':
+                    size = 8;
+                    break;
+                case 'P':
+                case 'O':
+                case 'S':
+                    size = sizeof(void *);
+                    break;
                 case 'f':
-                    size = sizeof(float); break;
+                    size = sizeof(float);
+                    break;
                 case 'd':
-                    size = sizeof(double); break;
+                    size = sizeof(double);
+                    break;
             }
             break;
         case '@': {
@@ -76,29 +92,44 @@
             // particular (or any) ABI.
             switch (val_type) {
                 case BYTEARRAY_TYPECODE:
-                case 'b': case 'B':
-                    align = size = 1; break;
-                case 'h': case 'H':
+                case 'b':
+                case 'B':
+                    align = size = 1;
+                    break;
+                case 'h':
+                case 'H':
                     align = alignof(short);
-                    size = sizeof(short); break;
-                case 'i': case 'I':
+                    size = sizeof(short);
+                    break;
+                case 'i':
+                case 'I':
                     align = alignof(int);
-                    size = sizeof(int); break;
-                case 'l': case 'L':
+                    size = sizeof(int);
+                    break;
+                case 'l':
+                case 'L':
                     align = alignof(long);
-                    size = sizeof(long); break;
-                case 'q': case 'Q':
+                    size = sizeof(long);
+                    break;
+                case 'q':
+                case 'Q':
                     align = alignof(long long);
-                    size = sizeof(long long); break;
-                case 'P': case 'O': case 'S':
-                    align = alignof(void*);
-                    size = sizeof(void*); break;
+                    size = sizeof(long long);
+                    break;
+                case 'P':
+                case 'O':
+                case 'S':
+                    align = alignof(void *);
+                    size = sizeof(void *);
+                    break;
                 case 'f':
                     align = alignof(float);
-                    size = sizeof(float); break;
+                    size = sizeof(float);
+                    break;
                 case 'd':
                     align = alignof(double);
-                    size = sizeof(double); break;
+                    size = sizeof(double);
+                    break;
             }
         }
     }
@@ -117,44 +148,44 @@
     mp_int_t val = 0;
     switch (typecode) {
         case 'b':
-            val = ((signed char*)p)[index];
+            val = ((signed char *)p)[index];
             break;
         case BYTEARRAY_TYPECODE:
         case 'B':
-            val = ((unsigned char*)p)[index];
+            val = ((unsigned char *)p)[index];
             break;
         case 'h':
-            val = ((short*)p)[index];
+            val = ((short *)p)[index];
             break;
         case 'H':
-            val = ((unsigned short*)p)[index];
+            val = ((unsigned short *)p)[index];
             break;
         case 'i':
-            return mp_obj_new_int(((int*)p)[index]);
+            return mp_obj_new_int(((int *)p)[index]);
         case 'I':
-            return mp_obj_new_int_from_uint(((unsigned int*)p)[index]);
+            return mp_obj_new_int_from_uint(((unsigned int *)p)[index]);
         case 'l':
-            return mp_obj_new_int(((long*)p)[index]);
+            return mp_obj_new_int(((long *)p)[index]);
         case 'L':
-            return mp_obj_new_int_from_uint(((unsigned long*)p)[index]);
+            return mp_obj_new_int_from_uint(((unsigned long *)p)[index]);
         #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
         case 'q':
-            return mp_obj_new_int_from_ll(((long long*)p)[index]);
+            return mp_obj_new_int_from_ll(((long long *)p)[index]);
         case 'Q':
-            return mp_obj_new_int_from_ull(((unsigned long long*)p)[index]);
+            return mp_obj_new_int_from_ull(((unsigned long long *)p)[index]);
         #endif
-#if MICROPY_PY_BUILTINS_FLOAT
+        #if MICROPY_PY_BUILTINS_FLOAT
         case 'f':
-            return mp_obj_new_float(((float*)p)[index]);
+            return mp_obj_new_float(((float *)p)[index]);
         case 'd':
-            return mp_obj_new_float(((double*)p)[index]);
-#endif
+            return mp_obj_new_float(((double *)p)[index]);
+        #endif
         // Extension to CPython: array of objects
         case 'O':
-            return ((mp_obj_t*)p)[index];
+            return ((mp_obj_t *)p)[index];
         // Extension to CPython: array of pointers
         case 'P':
-            return mp_obj_new_int((mp_int_t)(uintptr_t)((void**)p)[index]);
+            return mp_obj_new_int((mp_int_t)(uintptr_t)((void **)p)[index]);
     }
     return MP_OBJ_NEW_SMALL_INT(val);
 }
@@ -206,16 +237,20 @@
     if (val_type == 'O') {
         return (mp_obj_t)(mp_uint_t)val;
     } else if (val_type == 'S') {
-        const char *s_val = (const char*)(uintptr_t)(mp_uint_t)val;
+        const char *s_val = (const char *)(uintptr_t)(mp_uint_t)val;
         return mp_obj_new_str(s_val, strlen(s_val));
-#if MICROPY_PY_BUILTINS_FLOAT
+    #if MICROPY_PY_BUILTINS_FLOAT
     } else if (val_type == 'f') {
-        union { uint32_t i; float f; } fpu = {val};
+        union { uint32_t i;
+                float f;
+        } fpu = {val};
         return mp_obj_new_float(fpu.f);
     } else if (val_type == 'd') {
-        union { uint64_t i; double f; } fpu = {val};
+        union { uint64_t i;
+                double f;
+        } fpu = {val};
         return mp_obj_new_float(fpu.f);
-#endif
+    #endif
     } else if (is_signed(val_type)) {
         if ((long long)MP_SMALL_INT_MIN <= val && val <= (long long)MP_SMALL_INT_MAX) {
             return mp_obj_new_int((mp_int_t)val);
@@ -236,13 +271,13 @@
         memcpy(dest, &val, val_sz);
     } else if (MP_ENDIANNESS_BIG && big_endian) {
         // only copy the least-significant val_sz bytes
-        memcpy(dest, (byte*)&val + sizeof(mp_uint_t) - val_sz, val_sz);
+        memcpy(dest, (byte *)&val + sizeof(mp_uint_t) - val_sz, val_sz);
     } else {
         const byte *src;
         if (MP_ENDIANNESS_LITTLE) {
-            src = (const byte*)&val + val_sz;
+            src = (const byte *)&val + val_sz;
         } else {
-            src = (const byte*)&val + sizeof(mp_uint_t);
+            src = (const byte *)&val + sizeof(mp_uint_t);
         }
         while (val_sz--) {
             *dest++ = *--src;
@@ -271,15 +306,20 @@
         case 'O':
             val = (mp_uint_t)val_in;
             break;
-#if MICROPY_PY_BUILTINS_FLOAT
+        #if MICROPY_PY_BUILTINS_FLOAT
         case 'f': {
-            union { uint32_t i; float f; } fp_sp;
+            union { uint32_t i;
+                    float f;
+            } fp_sp;
             fp_sp.f = mp_obj_get_float(val_in);
             val = fp_sp.i;
             break;
         }
         case 'd': {
-            union { uint64_t i64; uint32_t i32[2]; double f; } fp_dp;
+            union { uint64_t i64;
+                    uint32_t i32[2];
+                    double f;
+            } fp_dp;
             fp_dp.f = mp_obj_get_float(val_in);
             if (BYTES_PER_WORD == 8) {
                 val = fp_dp.i64;
@@ -291,7 +331,7 @@
             }
             break;
         }
-#endif
+        #endif
         default:
             #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
             if (mp_obj_is_type(val_in, &mp_type_int)) {
@@ -317,24 +357,24 @@
 
 void mp_binary_set_val_array(char typecode, void *p, size_t index, mp_obj_t val_in) {
     switch (typecode) {
-#if MICROPY_PY_BUILTINS_FLOAT
+        #if MICROPY_PY_BUILTINS_FLOAT
         case 'f':
-            ((float*)p)[index] = mp_obj_get_float(val_in);
+            ((float *)p)[index] = mp_obj_get_float(val_in);
             break;
         case 'd':
-            ((double*)p)[index] = mp_obj_get_float(val_in);
+            ((double *)p)[index] = mp_obj_get_float(val_in);
             break;
-#endif
+        #endif
         // Extension to CPython: array of objects
         case 'O':
-            ((mp_obj_t*)p)[index] = val_in;
+            ((mp_obj_t *)p)[index] = val_in;
             break;
         default:
             #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
             if (mp_obj_is_type(val_in, &mp_type_int)) {
                 size_t size = mp_binary_get_size('@', typecode, NULL);
                 mp_obj_int_to_bytes_impl(val_in, MP_ENDIANNESS_BIG,
-                    size, (uint8_t*)p + index * size);
+                    size, (uint8_t *)p + index * size);
                 return;
             }
             #endif
@@ -345,49 +385,49 @@
 void mp_binary_set_val_array_from_int(char typecode, void *p, size_t index, mp_int_t val) {
     switch (typecode) {
         case 'b':
-            ((signed char*)p)[index] = val;
+            ((signed char *)p)[index] = val;
             break;
         case BYTEARRAY_TYPECODE:
         case 'B':
-            ((unsigned char*)p)[index] = val;
+            ((unsigned char *)p)[index] = val;
             break;
         case 'h':
-            ((short*)p)[index] = val;
+            ((short *)p)[index] = val;
             break;
         case 'H':
-            ((unsigned short*)p)[index] = val;
+            ((unsigned short *)p)[index] = val;
             break;
         case 'i':
-            ((int*)p)[index] = val;
+            ((int *)p)[index] = val;
             break;
         case 'I':
-            ((unsigned int*)p)[index] = val;
+            ((unsigned int *)p)[index] = val;
             break;
         case 'l':
-            ((long*)p)[index] = val;
+            ((long *)p)[index] = val;
             break;
         case 'L':
-            ((unsigned long*)p)[index] = val;
+            ((unsigned long *)p)[index] = val;
             break;
         #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
         case 'q':
-            ((long long*)p)[index] = val;
+            ((long long *)p)[index] = val;
             break;
         case 'Q':
-            ((unsigned long long*)p)[index] = val;
+            ((unsigned long long *)p)[index] = val;
             break;
         #endif
-#if MICROPY_PY_BUILTINS_FLOAT
+        #if MICROPY_PY_BUILTINS_FLOAT
         case 'f':
-            ((float*)p)[index] = val;
+            ((float *)p)[index] = val;
             break;
         case 'd':
-            ((double*)p)[index] = val;
+            ((double *)p)[index] = val;
             break;
-#endif
+        #endif
         // Extension to CPython: array of pointers
         case 'P':
-            ((void**)p)[index] = (void*)(uintptr_t)val;
+            ((void **)p)[index] = (void *)(uintptr_t)val;
             break;
     }
 }
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 819e3e1..a4bf7d9 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -90,9 +90,15 @@
     qstr mode = mp_obj_str_get_qstr(args[2]);
     mp_parse_input_kind_t parse_input_kind;
     switch (mode) {
-        case MP_QSTR_single: parse_input_kind = MP_PARSE_SINGLE_INPUT; break;
-        case MP_QSTR_exec: parse_input_kind = MP_PARSE_FILE_INPUT; break;
-        case MP_QSTR_eval: parse_input_kind = MP_PARSE_EVAL_INPUT; break;
+        case MP_QSTR_single:
+            parse_input_kind = MP_PARSE_SINGLE_INPUT;
+            break;
+        case MP_QSTR_exec:
+            parse_input_kind = MP_PARSE_FILE_INPUT;
+            break;
+        case MP_QSTR_eval:
+            parse_input_kind = MP_PARSE_EVAL_INPUT;
+            break;
         default:
             mp_raise_ValueError("bad compile mode");
     }
diff --git a/py/builtinhelp.c b/py/builtinhelp.c
index 033242b..1373563 100644
--- a/py/builtinhelp.c
+++ b/py/builtinhelp.c
@@ -33,18 +33,18 @@
 #if MICROPY_PY_BUILTINS_HELP
 
 const char mp_help_default_text[] =
-"Welcome to MicroPython!\n"
-"\n"
-"For online docs please visit http://docs.micropython.org/\n"
-"\n"
-"Control commands:\n"
-"  CTRL-A        -- on a blank line, enter raw REPL mode\n"
-"  CTRL-B        -- on a blank line, enter normal REPL mode\n"
-"  CTRL-C        -- interrupt a running program\n"
-"  CTRL-D        -- on a blank line, exit or do a soft reset\n"
-"  CTRL-E        -- on a blank line, enter paste mode\n"
-"\n"
-"For further help on a specific object, type help(obj)\n"
+    "Welcome to MicroPython!\n"
+    "\n"
+    "For online docs please visit http://docs.micropython.org/\n"
+    "\n"
+    "Control commands:\n"
+    "  CTRL-A        -- on a blank line, enter raw REPL mode\n"
+    "  CTRL-B        -- on a blank line, enter normal REPL mode\n"
+    "  CTRL-C        -- interrupt a running program\n"
+    "  CTRL-D        -- on a blank line, exit or do a soft reset\n"
+    "  CTRL-E        -- on a blank line, enter paste mode\n"
+    "\n"
+    "For further help on a specific object, type help(obj)\n"
 ;
 
 STATIC void mp_help_print_info_about_object(mp_obj_t name_o, mp_obj_t value) {
@@ -91,7 +91,7 @@
     #endif
 
     // sort the list so it's printed in alphabetical order
-    mp_obj_list_sort(1, &list, (mp_map_t*)&mp_const_empty_map);
+    mp_obj_list_sort(1, &list, (mp_map_t *)&mp_const_empty_map);
 
     // print the list of modules in a column-first order
     #define NUM_COLUMNS (4)
diff --git a/py/builtinimport.c b/py/builtinimport.c
index 23ab166..b188f3c 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -96,7 +96,7 @@
 }
 
 STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *dest) {
-#if MICROPY_PY_SYS
+    #if MICROPY_PY_SYS
     // extract the list of paths
     size_t path_num;
     mp_obj_t *path_items;
@@ -122,7 +122,7 @@
         // could not find a directory or file
         return MP_IMPORT_STAT_NO_EXIST;
     }
-#endif
+    #endif
 
     // mp_sys_path is empty, so just use the given file name
     vstr_add_strn(dest, file_str, file_len);
@@ -143,7 +143,7 @@
 #endif
 
 #if MICROPY_PERSISTENT_CODE_LOAD || MICROPY_MODULE_FROZEN_MPY
-STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, const char* source_name) {
+STATIC void do_execute_raw_code(mp_obj_t module_obj, mp_raw_code_t *raw_code, const char *source_name) {
     (void)source_name;
 
     #if MICROPY_PY___FILE__
@@ -244,14 +244,14 @@
 }
 
 mp_obj_t mp_builtin___import__(size_t n_args, const mp_obj_t *args) {
-#if DEBUG_PRINT
+    #if DEBUG_PRINT
     DEBUG_printf("__import__:\n");
     for (size_t i = 0; i < n_args; i++) {
         DEBUG_printf("  ");
         mp_obj_print(args[i], PRINT_REPR);
         DEBUG_printf("\n");
     }
-#endif
+    #endif
 
     mp_obj_t module_name = args[0];
     mp_obj_t fromtuple = mp_const_none;
@@ -290,12 +290,12 @@
         mp_map_elem_t *elem = mp_map_lookup(globals_map, MP_OBJ_NEW_QSTR(MP_QSTR___path__), MP_MAP_LOOKUP);
         bool is_pkg = (elem != NULL);
 
-#if DEBUG_PRINT
+        #if DEBUG_PRINT
         DEBUG_printf("Current module/package: ");
         mp_obj_print(this_name_q, PRINT_REPR);
         DEBUG_printf(", is_package: %d", is_pkg);
         DEBUG_printf("\n");
-#endif
+        #endif
 
         size_t this_name_l;
         const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l);
diff --git a/py/compile.c b/py/compile.c
index 885e318..225f207 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -47,14 +47,14 @@
 // define rules with a compile function
 #define DEF_RULE(rule, comp, kind, ...) PN_##rule,
 #define DEF_RULE_NC(rule, kind, ...)
-#include "py/grammar.h"
+    #include "py/grammar.h"
 #undef DEF_RULE
 #undef DEF_RULE_NC
     PN_const_object, // special node for a constant, generic Python object
 // define rules without a compile function
 #define DEF_RULE(rule, comp, kind, ...)
 #define DEF_RULE_NC(rule, kind, ...) PN_##rule,
-#include "py/grammar.h"
+    #include "py/grammar.h"
 #undef DEF_RULE
 #undef DEF_RULE_NC
 } pn_kind_t;
@@ -193,7 +193,7 @@
 STATIC void compile_error_set_line(compiler_t *comp, mp_parse_node_t pn) {
     // if the line of the error is unknown then try to update it from the pn
     if (comp->compile_error_line == 0 && MP_PARSE_NODE_IS_STRUCT(pn)) {
-        comp->compile_error_line = ((mp_parse_node_struct_t*)pn)->source_line;
+        comp->compile_error_line = ((mp_parse_node_struct_t *)pn)->source_line;
     }
 }
 
@@ -259,7 +259,7 @@
 
 STATIC void apply_to_single_or_list(compiler_t *comp, mp_parse_node_t pn, pn_kind_t pn_list_kind, apply_list_fun_t f) {
     if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, pn_list_kind)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
         for (int i = 0; i < num_nodes; i++) {
             f(comp, pns->nodes[i]);
@@ -350,7 +350,7 @@
         }
         return;
     } else if (MP_PARSE_NODE_IS_STRUCT(pn)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_or_test) {
             if (jump_if == false) {
@@ -409,7 +409,7 @@
     }
 
     if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
         if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) {
             int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1);
             if (assign_kind != ASSIGN_AUG_STORE) {
@@ -418,7 +418,7 @@
                 }
             }
             assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1]));
-            pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1];
+            pns1 = (mp_parse_node_struct_t *)pns1->nodes[n - 1];
         }
         if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) {
             if (assign_kind == ASSIGN_AUG_STORE) {
@@ -478,14 +478,14 @@
     }
     if (num_head != 0) {
         if (0 == have_star_index) {
-            c_assign(comp, ((mp_parse_node_struct_t*)node_head)->nodes[0], ASSIGN_STORE);
+            c_assign(comp, ((mp_parse_node_struct_t *)node_head)->nodes[0], ASSIGN_STORE);
         } else {
             c_assign(comp, node_head, ASSIGN_STORE);
         }
     }
     for (uint i = 0; i < num_tail; i++) {
         if (num_head + i == have_star_index) {
-            c_assign(comp, ((mp_parse_node_struct_t*)nodes_tail[i])->nodes[0], ASSIGN_STORE);
+            c_assign(comp, ((mp_parse_node_struct_t *)nodes_tail[i])->nodes[0], ASSIGN_STORE);
         } else {
             c_assign(comp, nodes_tail[i], ASSIGN_STORE);
         }
@@ -513,7 +513,7 @@
         }
     } else {
         // pn must be a struct
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         switch (MP_PARSE_NODE_STRUCT_KIND(pns)) {
             case PN_atom_expr_normal:
                 // lhs is an index or attribute
@@ -539,7 +539,7 @@
                     if (assign_kind != ASSIGN_STORE) {
                         goto cannot_assign;
                     }
-                    pns = (mp_parse_node_struct_t*)pns->nodes[0];
+                    pns = (mp_parse_node_struct_t *)pns->nodes[0];
                     goto testlist_comp;
                 }
                 break;
@@ -553,7 +553,7 @@
                     // empty list, assignment allowed
                     c_assign_tuple(comp, MP_PARSE_NODE_NULL, 0, NULL);
                 } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) {
-                    pns = (mp_parse_node_struct_t*)pns->nodes[0];
+                    pns = (mp_parse_node_struct_t *)pns->nodes[0];
                     goto testlist_comp;
                 } else {
                     // brackets around 1 item
@@ -566,10 +566,10 @@
         }
         return;
 
-        testlist_comp:
+    testlist_comp:
         // lhs is a sequence
         if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1];
+            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) {
                 // sequence of one item, with trailing comma
                 assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0]));
@@ -586,14 +586,14 @@
             }
         } else {
             // sequence with 2 items
-            sequence_with_2_items:
+        sequence_with_2_items:
             c_assign_tuple(comp, MP_PARSE_NODE_NULL, 2, pns->nodes);
         }
         return;
     }
     return;
 
-    cannot_assign:
+cannot_assign:
     compile_syntax_error(comp, pn, "can't assign to expression");
 }
 
@@ -650,7 +650,7 @@
         pn_kind = -1;
     } else {
         assert(MP_PARSE_NODE_IS_STRUCT(pn));
-        pn_kind = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn);
+        pn_kind = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pn);
     }
 
     if (pn_kind == PN_typedargslist_star || pn_kind == PN_varargslist_star) {
@@ -680,7 +680,7 @@
         } else if (pn_kind == PN_typedargslist_name) {
             // this parameter has a colon and/or equal specifier
 
-            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
             pn_id = pns->nodes[0];
             //pn_colon = pns->nodes[1]; // unused
             pn_equal = pns->nodes[2];
@@ -689,7 +689,7 @@
             assert(pn_kind == PN_varargslist_name); // should be
             // this parameter has an equal specifier
 
-            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
             pn_id = pns->nodes[0];
             pn_equal = pns->nodes[1];
         }
@@ -779,7 +779,7 @@
     }
 
     // get the scope for this function
-    scope_t *fscope = (scope_t*)pns->nodes[4];
+    scope_t *fscope = (scope_t *)pns->nodes[4];
 
     // compile the function definition
     compile_funcdef_lambdef(comp, fscope, pns->nodes[1], PN_typedargslist);
@@ -801,7 +801,7 @@
     EMIT(load_build_class);
 
     // scope for this class
-    scope_t *cscope = (scope_t*)pns->nodes[3];
+    scope_t *cscope = (scope_t *)pns->nodes[3];
 
     // compile the class
     close_over_variables_etc(comp, cscope, 0, 0);
@@ -835,13 +835,13 @@
     qstr attr = MP_PARSE_NODE_LEAF_ARG(name_nodes[1]);
     if (attr == MP_QSTR_bytecode) {
         *emit_options = MP_EMIT_OPT_BYTECODE;
-#if MICROPY_EMIT_NATIVE
+    #if MICROPY_EMIT_NATIVE
     } else if (attr == MP_QSTR_native) {
         *emit_options = MP_EMIT_OPT_NATIVE_PYTHON;
     } else if (attr == MP_QSTR_viper) {
         *emit_options = MP_EMIT_OPT_VIPER;
-#endif
-    #if MICROPY_EMIT_INLINE_ASM
+    #endif
+        #if MICROPY_EMIT_INLINE_ASM
     #if MICROPY_DYNAMIC_COMPILER
     } else if (attr == MP_QSTR_asm_thumb) {
         *emit_options = MP_EMIT_OPT_ASM;
@@ -851,7 +851,7 @@
     } else if (attr == ASM_DECORATOR_QSTR) {
         *emit_options = MP_EMIT_OPT_ASM;
     #endif
-    #endif
+        #endif
     } else {
         compile_syntax_error(comp, name_nodes[1], "invalid micropython decorator");
     }
@@ -883,7 +883,7 @@
     int num_built_in_decorators = 0;
     for (int i = 0; i < n; i++) {
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(nodes[i], PN_decorator)); // should be
-        mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t*)nodes[i];
+        mp_parse_node_struct_t *pns_decorator = (mp_parse_node_struct_t *)nodes[i];
 
         // nodes[0] contains the decorator function, which is a dotted name
         mp_parse_node_t *name_nodes;
@@ -913,16 +913,16 @@
     }
 
     // compile the body (funcdef, async funcdef or classdef) and get its name
-    mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t*)pns->nodes[1];
+    mp_parse_node_struct_t *pns_body = (mp_parse_node_struct_t *)pns->nodes[1];
     qstr body_name = 0;
     if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_funcdef) {
         body_name = compile_funcdef_helper(comp, pns_body, emit_options);
     #if MICROPY_PY_ASYNC_AWAIT
     } else if (MP_PARSE_NODE_STRUCT_KIND(pns_body) == PN_async_funcdef) {
         assert(MP_PARSE_NODE_IS_STRUCT(pns_body->nodes[0]));
-        mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns_body->nodes[0];
+        mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns_body->nodes[0];
         body_name = compile_funcdef_helper(comp, pns0, emit_options);
-        scope_t *fscope = (scope_t*)pns0->nodes[4];
+        scope_t *fscope = (scope_t *)pns0->nodes[4];
         fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
     #endif
     } else {
@@ -949,19 +949,19 @@
     if (MP_PARSE_NODE_IS_ID(pn)) {
         compile_delete_id(comp, MP_PARSE_NODE_LEAF_ARG(pn));
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_expr_normal)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
 
         compile_node(comp, pns->nodes[0]); // base of the atom_expr_normal node
 
         if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_atom_expr_trailers) {
                 int n = MP_PARSE_NODE_STRUCT_NUM_NODES(pns1);
                 for (int i = 0; i < n - 1; i++) {
                     compile_node(comp, pns1->nodes[i]);
                 }
                 assert(MP_PARSE_NODE_IS_STRUCT(pns1->nodes[n - 1]));
-                pns1 = (mp_parse_node_struct_t*)pns1->nodes[n - 1];
+                pns1 = (mp_parse_node_struct_t *)pns1->nodes[n - 1];
             }
             if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_trailer_bracket) {
                 compile_node(comp, pns1->nodes[0]);
@@ -977,16 +977,16 @@
         }
 
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_paren)) {
-        pn = ((mp_parse_node_struct_t*)pn)->nodes[0];
+        pn = ((mp_parse_node_struct_t *)pn)->nodes[0];
         if (MP_PARSE_NODE_IS_NULL(pn)) {
             goto cannot_delete;
         } else {
             assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_testlist_comp));
-            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
             // TODO perhaps factorise testlist_comp code with other uses of PN_testlist_comp
 
             if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-                mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+                mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
                 if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_testlist_comp_3b) {
                     // sequence of one item, with trailing comma
                     assert(MP_PARSE_NODE_IS_NULL(pns1->nodes[0]));
@@ -1006,7 +1006,7 @@
                 }
             } else {
                 // sequence with 2 items
-                sequence_with_2_items:
+            sequence_with_2_items:
                 c_del_stmt(comp, pns->nodes[0]);
                 c_del_stmt(comp, pns->nodes[1]);
             }
@@ -1051,10 +1051,10 @@
         // no argument to 'return', so return None
         EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
     } else if (MICROPY_COMP_RETURN_IF_EXPR
-        && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_test_if_expr)) {
+               && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_test_if_expr)) {
         // special case when returning an if-expression; to match CPython optimisation
-        mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t*)pns->nodes[0];
-        mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns_test_if_expr->nodes[1];
+        mp_parse_node_struct_t *pns_test_if_expr = (mp_parse_node_struct_t *)pns->nodes[0];
+        mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t *)pns_test_if_expr->nodes[1];
 
         uint l_fail = comp_next_label(comp);
         c_if_cond(comp, pns_test_if_else->nodes[0], false, l_fail); // condition
@@ -1079,7 +1079,7 @@
         EMIT_ARG(raise_varargs, 0);
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_raise_stmt_arg)) {
         // raise x from y
-        pns = (mp_parse_node_struct_t*)pns->nodes[0];
+        pns = (mp_parse_node_struct_t *)pns->nodes[0];
         compile_node(comp, pns->nodes[0]);
         compile_node(comp, pns->nodes[1]);
         EMIT_ARG(raise_varargs, 2);
@@ -1096,7 +1096,7 @@
 STATIC void do_import_name(compiler_t *comp, mp_parse_node_t pn, qstr *q_base) {
     bool is_as = false;
     if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_as_name)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         // a name of the form x as y; unwrap it
         *q_base = MP_PARSE_NODE_LEAF_ARG(pns->nodes[1]);
         pn = pns->nodes[0];
@@ -1115,7 +1115,7 @@
         EMIT_ARG(import, q_full, MP_EMIT_IMPORT_NAME);
     } else {
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_dotted_name)); // should be
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         {
             // a name of the form a.b.c
             if (!is_as) {
@@ -1174,7 +1174,7 @@
             pn_import_source = MP_PARSE_NODE_NULL;
         } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn_import_source, PN_import_from_2b)) {
             // This covers relative imports starting with dot(s) like "from .foo import"
-            mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t*)pn_import_source;
+            mp_parse_node_struct_t *pns_2b = (mp_parse_node_struct_t *)pn_import_source;
             pn_rel = pns_2b->nodes[0];
             pn_import_source = pns_2b->nodes[1];
             assert(!MP_PARSE_NODE_IS_NULL(pn_import_source)); // should not be
@@ -1225,7 +1225,7 @@
         int n = mp_parse_node_extract_list(&pns->nodes[1], PN_import_as_names, &pn_nodes);
         for (int i = 0; i < n; i++) {
             assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name));
-            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i];
+            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pn_nodes[i];
             qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id
             EMIT_ARG(load_const_str, id2);
         }
@@ -1236,7 +1236,7 @@
         do_import_name(comp, pn_import_source, &dummy_q);
         for (int i = 0; i < n; i++) {
             assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_nodes[i], PN_import_as_name));
-            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pn_nodes[i];
+            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pn_nodes[i];
             qstr id2 = MP_PARSE_NODE_LEAF_ARG(pns3->nodes[0]); // should be id
             EMIT_ARG(import, id2, MP_EMIT_IMPORT_FROM);
             if (MP_PARSE_NODE_IS_NULL(pns3->nodes[1])) {
@@ -1349,7 +1349,7 @@
     int n_elif = mp_parse_node_extract_list(&pns->nodes[2], PN_if_stmt_elif_list, &pn_elif);
     for (int i = 0; i < n_elif; i++) {
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_elif[i], PN_if_stmt_elif)); // should be
-        mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t*)pn_elif[i];
+        mp_parse_node_struct_t *pns_elif = (mp_parse_node_struct_t *)pn_elif[i];
 
         // optimisation: don't emit anything when "if False"
         if (!mp_parse_node_is_const_false(pns_elif->nodes[0])) {
@@ -1518,11 +1518,11 @@
     // this is actually slower, but uses no heap memory
     // for viper it will be much, much faster
     if (/*comp->scope_cur->emit_options == MP_EMIT_OPT_VIPER &&*/ MP_PARSE_NODE_IS_ID(pns->nodes[0]) && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_atom_expr_normal)) {
-        mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t*)pns->nodes[1];
+        mp_parse_node_struct_t *pns_it = (mp_parse_node_struct_t *)pns->nodes[1];
         if (MP_PARSE_NODE_IS_ID(pns_it->nodes[0])
             && MP_PARSE_NODE_LEAF_ARG(pns_it->nodes[0]) == MP_QSTR_range
-            && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pns_it->nodes[1]) == PN_trailer_paren) {
-            mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t*)pns_it->nodes[1])->nodes[0];
+            && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pns_it->nodes[1]) == PN_trailer_paren) {
+            mp_parse_node_t pn_range_args = ((mp_parse_node_struct_t *)pns_it->nodes[1])->nodes[0];
             mp_parse_node_t *args;
             int n_args = mp_parse_node_extract_list(&pn_range_args, PN_arglist, &args);
             mp_parse_node_t pn_range_start;
@@ -1551,13 +1551,13 @@
                 }
                 // arguments must be able to be compiled as standard expressions
                 if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_start)) {
-                    int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_start);
+                    int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pn_range_start);
                     if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) {
                         optimize = false;
                     }
                 }
                 if (optimize && MP_PARSE_NODE_IS_STRUCT(pn_range_end)) {
-                    int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_range_end);
+                    int k = MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pn_range_end);
                     if (k == PN_arglist_star || k == PN_arglist_dbl_star || k == PN_argument) {
                         optimize = false;
                     }
@@ -1614,7 +1614,7 @@
 
     for (int i = 0; i < n_except; i++) {
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(pn_excepts[i], PN_try_stmt_except)); // should be
-        mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t*)pn_excepts[i];
+        mp_parse_node_struct_t *pns_except = (mp_parse_node_struct_t *)pn_excepts[i];
 
         qstr qstr_exception_local = 0;
         uint end_finally_label = comp_next_label(comp);
@@ -1633,7 +1633,7 @@
             // this exception handler requires a match to a certain type of exception
             mp_parse_node_t pns_exception_expr = pns_except->nodes[0];
             if (MP_PARSE_NODE_IS_STRUCT(pns_exception_expr)) {
-                mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns_exception_expr;
+                mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pns_exception_expr;
                 if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_try_stmt_as_name) {
                     // handler binds the exception to a local
                     pns_exception_expr = pns3->nodes[0];
@@ -1713,7 +1713,7 @@
 STATIC void compile_try_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should be
     {
-        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1];
+        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
         if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_try_stmt_finally) {
             // just try-finally
             compile_try_finally(comp, pns->nodes[0], 0, NULL, MP_PARSE_NODE_NULL, pns2->nodes[0]);
@@ -1726,7 +1726,7 @@
                 compile_try_except(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1]);
             } else {
                 // have finally
-                compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t*)pns2->nodes[2])->nodes[0]);
+                compile_try_finally(comp, pns->nodes[0], n_except, pn_excepts, pns2->nodes[1], ((mp_parse_node_struct_t *)pns2->nodes[2])->nodes[0]);
             }
         } else {
             // just try-except
@@ -1745,7 +1745,7 @@
         uint l_end = comp_next_label(comp);
         if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) {
             // this pre-bit is of the form "a as b"
-            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0];
+            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)nodes[0];
             compile_node(comp, pns->nodes[0]);
             compile_increase_except_level(comp, l_end, MP_EMIT_SETUP_BLOCK_WITH);
             c_assign(comp, pns->nodes[1], ASSIGN_STORE);
@@ -1851,7 +1851,7 @@
 
         if (MP_PARSE_NODE_IS_STRUCT_KIND(nodes[0], PN_with_item)) {
             // this pre-bit is of the form "a as b"
-            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)nodes[0];
+            mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)nodes[0];
             compile_node(comp, pns->nodes[0]);
             EMIT(dup_top);
             compile_await_object_method(comp, MP_QSTR___aenter__);
@@ -1963,11 +1963,11 @@
 
 STATIC void compile_async_stmt(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[0]));
-    mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0];
+    mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns->nodes[0];
     if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_funcdef) {
         // async def
         compile_funcdef(comp, pns0);
-        scope_t *fscope = (scope_t*)pns0->nodes[4];
+        scope_t *fscope = (scope_t *)pns0->nodes[4];
         fscope->scope_flags |= MP_SCOPE_FLAG_GENERATOR;
     } else if (MP_PARSE_NODE_STRUCT_KIND(pns0) == PN_for_stmt) {
         // async for
@@ -2000,7 +2000,7 @@
             }
         }
     } else if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
         int kind = MP_PARSE_NODE_STRUCT_KIND(pns1);
         if (kind == PN_expr_stmt_augassign) {
             c_assign(comp, pns->nodes[0], ASSIGN_AUG_LOAD); // lhs load for aug assign
@@ -2029,8 +2029,8 @@
             #if MICROPY_COMP_DOUBLE_TUPLE_ASSIGN
             if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_testlist_star_expr)
                 && MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_star_expr)) {
-                mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t*)pns->nodes[0];
-                pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+                mp_parse_node_struct_t *pns0 = (mp_parse_node_struct_t *)pns->nodes[0];
+                pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
                 uint32_t n_pns0 = MP_PARSE_NODE_STRUCT_NUM_NODES(pns0);
                 // Can only optimise a tuple-to-tuple assignment when all of the following hold:
                 //  - equal number of items in LHS and RHS tuples
@@ -2080,7 +2080,7 @@
 
 STATIC void compile_test_if_expr(compiler_t *comp, mp_parse_node_struct_t *pns) {
     assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_test_if_else));
-    mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t*)pns->nodes[1];
+    mp_parse_node_struct_t *pns_test_if_else = (mp_parse_node_struct_t *)pns->nodes[1];
 
     uint l_fail = comp_next_label(comp);
     uint l_end = comp_next_label(comp);
@@ -2102,7 +2102,7 @@
     }
 
     // get the scope for this lambda
-    scope_t *this_scope = (scope_t*)pns->nodes[2];
+    scope_t *this_scope = (scope_t *)pns->nodes[2];
 
     // compile the lambda definition
     compile_funcdef_lambdef(comp, this_scope, pns->nodes[0], PN_varargslist);
@@ -2151,7 +2151,7 @@
             EMIT_ARG(binary_op, op);
         } else {
             assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[i])); // should be
-            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[i];
+            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[i];
             int kind = MP_PARSE_NODE_STRUCT_KIND(pns2);
             if (kind == PN_comp_op_not_in) {
                 EMIT_ARG(binary_op, MP_BINARY_OP_NOT_IN);
@@ -2230,10 +2230,10 @@
 
     // get the array of trailers (known to be an array of PARSE_NODE_STRUCT)
     size_t num_trail = 1;
-    mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t**)&pns->nodes[1];
+    mp_parse_node_struct_t **pns_trail = (mp_parse_node_struct_t **)&pns->nodes[1];
     if (MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_atom_expr_trailers) {
         num_trail = MP_PARSE_NODE_STRUCT_NUM_NODES(pns_trail[0]);
-        pns_trail = (mp_parse_node_struct_t**)&pns_trail[0]->nodes[0];
+        pns_trail = (mp_parse_node_struct_t **)&pns_trail[0]->nodes[0];
     }
 
     // the current index into the array of trailers
@@ -2282,19 +2282,19 @@
             i = 1;
         }
 
-    #if MICROPY_COMP_CONST_LITERAL && MICROPY_PY_COLLECTIONS_ORDEREDDICT
-    // handle special OrderedDict constructor
+        #if MICROPY_COMP_CONST_LITERAL && MICROPY_PY_COLLECTIONS_ORDEREDDICT
+        // handle special OrderedDict constructor
     } else if (MP_PARSE_NODE_IS_ID(pns->nodes[0])
-        && MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]) == MP_QSTR_OrderedDict
-        && MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_trailer_paren
-        && MP_PARSE_NODE_IS_STRUCT_KIND(pns_trail[0]->nodes[0], PN_atom_brace)) {
+               && MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]) == MP_QSTR_OrderedDict
+               && MP_PARSE_NODE_STRUCT_KIND(pns_trail[0]) == PN_trailer_paren
+               && MP_PARSE_NODE_IS_STRUCT_KIND(pns_trail[0]->nodes[0], PN_atom_brace)) {
         // at this point we have matched "OrderedDict({...})"
 
         EMIT_ARG(call_function, 0, 0, 0);
-        mp_parse_node_struct_t *pns_dict = (mp_parse_node_struct_t*)pns_trail[0]->nodes[0];
+        mp_parse_node_struct_t *pns_dict = (mp_parse_node_struct_t *)pns_trail[0]->nodes[0];
         compile_atom_brace_helper(comp, pns_dict, false);
         i = 1;
-    #endif
+        #endif
     }
 
     // compile the remaining trailers
@@ -2337,7 +2337,7 @@
     mp_parse_node_struct_t *star_args_node = NULL, *dblstar_args_node = NULL;
     for (int i = 0; i < n_args; i++) {
         if (MP_PARSE_NODE_IS_STRUCT(args[i])) {
-            mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t*)args[i];
+            mp_parse_node_struct_t *pns_arg = (mp_parse_node_struct_t *)args[i];
             if (MP_PARSE_NODE_STRUCT_KIND(pns_arg) == PN_arglist_star) {
                 if (star_flags & MP_EMIT_STAR_FLAG_SINGLE) {
                     compile_syntax_error(comp, (mp_parse_node_t)pns_arg, "can't have multiple *x");
@@ -2369,7 +2369,7 @@
                 goto normal_argument;
             }
         } else {
-            normal_argument:
+        normal_argument:
             if (star_flags) {
                 compile_syntax_error(comp, args[i], "non-keyword arg after */**");
                 return;
@@ -2410,7 +2410,7 @@
 STATIC void compile_comprehension(compiler_t *comp, mp_parse_node_struct_t *pns, scope_kind_t kind) {
     assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2);
     assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
-    mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1];
+    mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t *)pns->nodes[1];
 
     if (comp->pass == MP_PASS_SCOPE) {
         // create a new scope for this comprehension
@@ -2420,7 +2420,7 @@
     }
 
     // get the scope for this comprehension
-    scope_t *this_scope = (scope_t*)pns_comp_for->nodes[3];
+    scope_t *this_scope = (scope_t *)pns_comp_for->nodes[3];
 
     // compile the comprehension
     close_over_variables_etc(comp, this_scope, 0, 0);
@@ -2438,10 +2438,10 @@
         c_tuple(comp, MP_PARSE_NODE_NULL, NULL);
     } else {
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp));
-        pns = (mp_parse_node_struct_t*)pns->nodes[0];
+        pns = (mp_parse_node_struct_t *)pns->nodes[0];
         assert(!MP_PARSE_NODE_IS_NULL(pns->nodes[1]));
         if (MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])) {
-            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[1];
+            mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_testlist_comp_3b) {
                 // tuple of one item, with trailing comma
                 assert(MP_PARSE_NODE_IS_NULL(pns2->nodes[0]));
@@ -2458,7 +2458,7 @@
             }
         } else {
             // tuple with 2 items
-            tuple_with_2_items:
+        tuple_with_2_items:
             c_tuple(comp, MP_PARSE_NODE_NULL, pns);
         }
     }
@@ -2469,9 +2469,9 @@
         // empty list
         EMIT_ARG(build, 0, MP_EMIT_BUILD_LIST);
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) {
-        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)pns->nodes[0];
+        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)pns->nodes[0];
         if (MP_PARSE_NODE_IS_STRUCT(pns2->nodes[1])) {
-            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t*)pns2->nodes[1];
+            mp_parse_node_struct_t *pns3 = (mp_parse_node_struct_t *)pns2->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns3) == PN_testlist_comp_3b) {
                 // list of one item, with trailing comma
                 assert(MP_PARSE_NODE_IS_NULL(pns3->nodes[0]));
@@ -2491,7 +2491,7 @@
             }
         } else {
             // list with 2 items
-            list_with_2_items:
+        list_with_2_items:
             compile_node(comp, pns2->nodes[0]);
             compile_node(comp, pns2->nodes[1]);
             EMIT_ARG(build, 2, MP_EMIT_BUILD_LIST);
@@ -2511,7 +2511,7 @@
             EMIT_ARG(build, 0, MP_EMIT_BUILD_MAP);
         }
     } else if (MP_PARSE_NODE_IS_STRUCT(pn)) {
-        pns = (mp_parse_node_struct_t*)pn;
+        pns = (mp_parse_node_struct_t *)pn;
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker_item) {
             // dict with one element
             if (create_map) {
@@ -2521,7 +2521,7 @@
             EMIT(store_map);
         } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) {
             assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed
-            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) {
                 // dict/set with multiple elements
 
@@ -2595,7 +2595,7 @@
         }
     } else {
         // set with one element
-        set_with_one_element:
+    set_with_one_element:
         #if MICROPY_PY_BUILTINS_SET
         compile_node(comp, pn);
         EMIT_ARG(build, 1, MP_EMIT_BUILD_SET);
@@ -2629,7 +2629,7 @@
     if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_2) {
         compile_node(comp, pns->nodes[0]); // start of slice
         assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be
-        pns = (mp_parse_node_struct_t*)pns->nodes[1];
+        pns = (mp_parse_node_struct_t *)pns->nodes[1];
     } else {
         // pns is a PN_subscript_3, load None for start of slice
         EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
@@ -2642,7 +2642,7 @@
         EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
         EMIT_ARG(build, 2, MP_EMIT_BUILD_SLICE);
     } else if (MP_PARSE_NODE_IS_STRUCT(pn)) {
-        pns = (mp_parse_node_struct_t*)pn;
+        pns = (mp_parse_node_struct_t *)pn;
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3c) {
             EMIT_ARG(load_const_tok, MP_TOKEN_KW_NONE);
             pn = pns->nodes[0];
@@ -2657,7 +2657,7 @@
         } else if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_subscript_3d) {
             compile_node(comp, pns->nodes[0]);
             assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should always be
-            pns = (mp_parse_node_struct_t*)pns->nodes[1];
+            pns = (mp_parse_node_struct_t *)pns->nodes[1];
             assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_sliceop); // should always be
             if (MP_PARSE_NODE_IS_NULL(pns->nodes[0])) {
                 // [?:x:]
@@ -2702,7 +2702,7 @@
         EMIT_ARG(yield, MP_EMIT_YIELD_VALUE);
         reserve_labels_for_native(comp, 1);
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_yield_arg_from)) {
-        pns = (mp_parse_node_struct_t*)pns->nodes[0];
+        pns = (mp_parse_node_struct_t *)pns->nodes[0];
         compile_node(comp, pns->nodes[0]);
         compile_yield_from(comp);
     } else {
@@ -2736,13 +2736,13 @@
     EMIT_ARG(load_const_obj, get_const_object(pns));
 }
 
-typedef void (*compile_function_t)(compiler_t*, mp_parse_node_struct_t*);
+typedef void (*compile_function_t)(compiler_t *, mp_parse_node_struct_t *);
 STATIC const compile_function_t compile_function[] = {
 // only define rules with a compile function
 #define c(f) compile_##f
 #define DEF_RULE(rule, comp, kind, ...) comp,
 #define DEF_RULE_NC(rule, kind, ...)
-#include "py/grammar.h"
+    #include "py/grammar.h"
 #undef c
 #undef DEF_RULE
 #undef DEF_RULE_NC
@@ -2774,8 +2774,12 @@
     } else if (MP_PARSE_NODE_IS_LEAF(pn)) {
         uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn);
         switch (MP_PARSE_NODE_LEAF_KIND(pn)) {
-            case MP_PARSE_NODE_ID: compile_load_id(comp, arg); break;
-            case MP_PARSE_NODE_STRING: EMIT_ARG(load_const_str, arg); break;
+            case MP_PARSE_NODE_ID:
+                compile_load_id(comp, arg);
+                break;
+            case MP_PARSE_NODE_STRING:
+                EMIT_ARG(load_const_str, arg);
+                break;
             case MP_PARSE_NODE_BYTES:
                 // only create and load the actual bytes object on the last pass
                 if (comp->pass != MP_PASS_EMIT) {
@@ -2786,18 +2790,19 @@
                     EMIT_ARG(load_const_obj, mp_obj_new_bytes(data, len));
                 }
                 break;
-            case MP_PARSE_NODE_TOKEN: default:
+            case MP_PARSE_NODE_TOKEN:
+            default:
                 if (arg == MP_TOKEN_NEWLINE) {
                     // this can occur when file_input lets through a NEWLINE (eg if file starts with a newline)
                     // or when single_input lets through a NEWLINE (user enters a blank line)
                     // do nothing
                 } else {
-                  EMIT_ARG(load_const_tok, arg);
+                    EMIT_ARG(load_const_tok, arg);
                 }
                 break;
         }
     } else {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         EMIT_ARG(set_source_line, pns->source_line);
         assert(MP_PARSE_NODE_STRUCT_KIND(pns) <= PN_const_object);
         compile_function_t f = compile_function[MP_PARSE_NODE_STRUCT_KIND(pns)];
@@ -2847,7 +2852,7 @@
         }
     } else {
         assert(MP_PARSE_NODE_IS_STRUCT(pn));
-        pns = (mp_parse_node_struct_t*)pn;
+        pns = (mp_parse_node_struct_t *)pn;
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == pn_name) {
             // named parameter with possible annotation
             param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
@@ -2880,7 +2885,7 @@
                 assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_tfpdef)); // should be
                 // named star with possible annotation
                 comp->scope_cur->scope_flags |= MP_SCOPE_FLAG_VARARGS;
-                pns = (mp_parse_node_struct_t*)pns->nodes[0];
+                pns = (mp_parse_node_struct_t *)pns->nodes[0];
                 param_name = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]);
             }
         } else {
@@ -2927,7 +2932,7 @@
     c_assign(comp, pns_comp_for->nodes[0], ASSIGN_STORE);
     mp_parse_node_t pn_iter = pns_comp_for->nodes[2];
 
-    tail_recursion:
+tail_recursion:
     if (MP_PARSE_NODE_IS_NULL(pn_iter)) {
         // no more nested if/for; compile inner expression
         compile_node(comp, pn_inner_expr);
@@ -2938,16 +2943,16 @@
         } else {
             EMIT_ARG(store_comp, comp->scope_cur->kind, 4 * for_depth + 5);
         }
-    } else if (MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_if) {
+    } else if (MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pn_iter) == PN_comp_if) {
         // if condition
-        mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t*)pn_iter;
+        mp_parse_node_struct_t *pns_comp_if = (mp_parse_node_struct_t *)pn_iter;
         c_if_cond(comp, pns_comp_if->nodes[0], false, l_top);
         pn_iter = pns_comp_if->nodes[1];
         goto tail_recursion;
     } else {
-        assert(MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)pn_iter) == PN_comp_for); // should be
+        assert(MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)pn_iter) == PN_comp_for); // should be
         // for loop
-        mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t*)pn_iter;
+        mp_parse_node_struct_t *pns_comp_for2 = (mp_parse_node_struct_t *)pn_iter;
         compile_node(comp, pns_comp_for2->nodes[1]);
         EMIT_ARG(get_iter, true);
         compile_scope_comp_iter(comp, pns_comp_for2, pn_inner_expr, for_depth + 1);
@@ -2959,7 +2964,7 @@
 }
 
 STATIC void check_for_doc_string(compiler_t *comp, mp_parse_node_t pn) {
-#if MICROPY_ENABLE_DOC_STRING
+    #if MICROPY_ENABLE_DOC_STRING
     // see http://www.python.org/dev/peps/pep-0257/
 
     // look for the first statement
@@ -2967,7 +2972,7 @@
         // a statement; fall through
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_file_input_2)) {
         // file input; find the first non-newline node
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         int num_nodes = MP_PARSE_NODE_STRUCT_NUM_NODES(pns);
         for (int i = 0; i < num_nodes; i++) {
             pn = pns->nodes[i];
@@ -2979,28 +2984,28 @@
         // if we didn't find a non-newline then it's okay to fall through; pn will be a newline and so doc-string test below will fail gracefully
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_suite_block_stmts)) {
         // a list of statements; get the first one
-        pn = ((mp_parse_node_struct_t*)pn)->nodes[0];
+        pn = ((mp_parse_node_struct_t *)pn)->nodes[0];
     } else {
         return;
     }
 
     // check the first statement for a doc string
     if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_expr_stmt)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         if ((MP_PARSE_NODE_IS_LEAF(pns->nodes[0])
-                && MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING)
+             && MP_PARSE_NODE_LEAF_KIND(pns->nodes[0]) == MP_PARSE_NODE_STRING)
             || (MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_const_object)
-                && mp_obj_is_str(get_const_object((mp_parse_node_struct_t*)pns->nodes[0])))) {
-                // compile the doc string
-                compile_node(comp, pns->nodes[0]);
-                // store the doc string
-                compile_store_id(comp, MP_QSTR___doc__);
+                && mp_obj_is_str(get_const_object((mp_parse_node_struct_t *)pns->nodes[0])))) {
+            // compile the doc string
+            compile_node(comp, pns->nodes[0]);
+            // store the doc string
+            compile_store_id(comp, MP_QSTR___doc__);
         }
     }
-#else
+    #else
     (void)comp;
     (void)pn;
-#endif
+    #endif
 }
 
 STATIC void compile_scope(compiler_t *comp, scope_t *scope, pass_kind_t pass) {
@@ -3020,7 +3025,7 @@
     // compile
     if (MP_PARSE_NODE_IS_STRUCT_KIND(scope->pn, PN_eval_input)) {
         assert(scope->kind == SCOPE_MODULE);
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
         compile_node(comp, pns->nodes[0]); // compile the expression
         EMIT(return_value);
     } else if (scope->kind == SCOPE_MODULE) {
@@ -3032,7 +3037,7 @@
         EMIT(return_value);
     } else if (scope->kind == SCOPE_FUNCTION) {
         assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
         assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef);
 
         // work out number of parameters, keywords and default parameters, and add them to the id_info array
@@ -3057,7 +3062,7 @@
         }
     } else if (scope->kind == SCOPE_LAMBDA) {
         assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
         assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 3);
 
         // Set the source line number for the start of the lambda
@@ -3082,10 +3087,10 @@
         // a bit of a hack at the moment
 
         assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
         assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 2);
         assert(MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[1], PN_comp_for));
-        mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t*)pns->nodes[1];
+        mp_parse_node_struct_t *pns_comp_for = (mp_parse_node_struct_t *)pns->nodes[1];
 
         // We need a unique name for the comprehension argument (the iterator).
         // CPython uses .0, but we should be able to use anything that won't
@@ -3132,7 +3137,7 @@
     } else {
         assert(scope->kind == SCOPE_CLASS);
         assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
         assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_classdef);
 
         if (comp->pass == MP_PASS_SCOPE) {
@@ -3184,7 +3189,7 @@
 
     // get the function definition parse node
     assert(MP_PARSE_NODE_IS_STRUCT(scope->pn));
-    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)scope->pn;
+    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)scope->pn;
     assert(MP_PARSE_NODE_STRUCT_KIND(pns) == PN_funcdef);
 
     //qstr f_id = MP_PARSE_NODE_LEAF_ARG(pns->nodes[0]); // function name
@@ -3207,11 +3212,21 @@
         if (MP_PARSE_NODE_IS_ID(pn_annotation)) {
             qstr ret_type = MP_PARSE_NODE_LEAF_ARG(pn_annotation);
             switch (ret_type) {
-                case MP_QSTR_object: type_sig = MP_NATIVE_TYPE_OBJ; break;
-                case MP_QSTR_bool: type_sig = MP_NATIVE_TYPE_BOOL; break;
-                case MP_QSTR_int: type_sig = MP_NATIVE_TYPE_INT; break;
-                case MP_QSTR_uint: type_sig = MP_NATIVE_TYPE_UINT; break;
-                default: compile_syntax_error(comp, pn_annotation, "unknown type"); return;
+                case MP_QSTR_object:
+                    type_sig = MP_NATIVE_TYPE_OBJ;
+                    break;
+                case MP_QSTR_bool:
+                    type_sig = MP_NATIVE_TYPE_BOOL;
+                    break;
+                case MP_QSTR_int:
+                    type_sig = MP_NATIVE_TYPE_INT;
+                    break;
+                case MP_QSTR_uint:
+                    type_sig = MP_NATIVE_TYPE_UINT;
+                    break;
+                default:
+                    compile_syntax_error(comp, pn_annotation, "unknown type");
+                    return;
             }
         } else {
             compile_syntax_error(comp, pn_annotation, "return annotation must be an identifier");
@@ -3224,7 +3239,7 @@
 
     for (int i = 0; i < num; i++) {
         assert(MP_PARSE_NODE_IS_STRUCT(nodes[i]));
-        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t*)nodes[i];
+        mp_parse_node_struct_t *pns2 = (mp_parse_node_struct_t *)nodes[i];
         if (MP_PARSE_NODE_STRUCT_KIND(pns2) == PN_pass_stmt) {
             // no instructions
             continue;
@@ -3240,7 +3255,7 @@
         if (!MP_PARSE_NODE_IS_NULL(pns2->nodes[1])) {
             goto not_an_instruction;
         }
-        pns2 = (mp_parse_node_struct_t*)pns2->nodes[0];
+        pns2 = (mp_parse_node_struct_t *)pns2->nodes[0];
         if (MP_PARSE_NODE_STRUCT_KIND(pns2) != PN_atom_expr_normal) {
             goto not_an_instruction;
         }
@@ -3254,7 +3269,7 @@
         // parse node looks like an instruction
         // get instruction name and args
         qstr op = MP_PARSE_NODE_LEAF_ARG(pns2->nodes[0]);
-        pns2 = (mp_parse_node_struct_t*)pns2->nodes[1]; // PN_trailer_paren
+        pns2 = (mp_parse_node_struct_t *)pns2->nodes[1]; // PN_trailer_paren
         mp_parse_node_t *pn_arg;
         int n_args = mp_parse_node_extract_list(&pns2->nodes[0], PN_arglist, &pn_arg);
 
@@ -3277,7 +3292,7 @@
                 return;
             }
             if (pass > MP_PASS_SCOPE) {
-                mp_asm_base_align((mp_asm_base_t*)comp->emit_inline_asm,
+                mp_asm_base_align((mp_asm_base_t *)comp->emit_inline_asm,
                     MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[0]));
             }
         } else if (op == MP_QSTR_data) {
@@ -3292,7 +3307,7 @@
                         compile_syntax_error(comp, nodes[i], "'data' requires integer arguments");
                         return;
                     }
-                    mp_asm_base_data((mp_asm_base_t*)comp->emit_inline_asm,
+                    mp_asm_base_data((mp_asm_base_t *)comp->emit_inline_asm,
                         bytesize, MP_PARSE_NODE_LEAF_SMALL_INT(pn_arg[j]));
                 }
             }
@@ -3312,9 +3327,9 @@
         EMIT_INLINE_ASM_ARG(end_pass, type_sig);
 
         if (comp->pass == MP_PASS_EMIT) {
-            void *f = mp_asm_base_get_code((mp_asm_base_t*)comp->emit_inline_asm);
+            void *f = mp_asm_base_get_code((mp_asm_base_t *)comp->emit_inline_asm);
             mp_emit_glue_assign_native(comp->scope_cur->raw_code, MP_CODE_NATIVE_ASM,
-                f, mp_asm_base_get_code_size((mp_asm_base_t*)comp->emit_inline_asm),
+                f, mp_asm_base_get_code_size((mp_asm_base_t *)comp->emit_inline_asm),
                 NULL,
                 #if MICROPY_PERSISTENT_CODE_SAVE
                 0, 0, 0, 0, NULL,
@@ -3340,7 +3355,9 @@
             if (id->flags & ID_FLAG_IS_STAR_PARAM) {
                 if (id_param != NULL) {
                     // swap star param with last param
-                    id_info_t temp = *id_param; *id_param = *id; *id = temp;
+                    id_info_t temp = *id_param;
+                    *id_param = *id;
+                    *id = temp;
                 }
                 break;
             } else if (id_param == NULL && id->flags == ID_FLAG_IS_PARAM) {
@@ -3485,9 +3502,9 @@
     emit_bc_set_max_num_labels(emit_bc, max_num_labels);
 
     // compile pass 2 and 3
-#if MICROPY_EMIT_NATIVE
+    #if MICROPY_EMIT_NATIVE
     emit_t *emit_native = NULL;
-#endif
+    #endif
     for (scope_t *s = comp->scope_head; s != NULL && comp->compile_error == MP_OBJ_NULL; s = s->next) {
         #if MICROPY_EMIT_INLINE_ASM
         if (s->emit_options == MP_EMIT_OPT_ASM) {
@@ -3520,7 +3537,7 @@
 
             switch (s->emit_options) {
 
-#if MICROPY_EMIT_NATIVE
+                #if MICROPY_EMIT_NATIVE
                 case MP_EMIT_OPT_NATIVE_PYTHON:
                 case MP_EMIT_OPT_VIPER:
                     if (emit_native == NULL) {
@@ -3529,7 +3546,7 @@
                     comp->emit_method_table = NATIVE_EMITTER_TABLE;
                     comp->emit = emit_native;
                     break;
-#endif // MICROPY_EMIT_NATIVE
+                #endif // MICROPY_EMIT_NATIVE
 
                 default:
                     comp->emit = emit_bc;
@@ -3566,11 +3583,11 @@
     // free the emitters
 
     emit_bc_free(emit_bc);
-#if MICROPY_EMIT_NATIVE
+    #if MICROPY_EMIT_NATIVE
     if (emit_native != NULL) {
         NATIVE_EMITTER(free)(emit_native);
     }
-#endif
+    #endif
     #if MICROPY_EMIT_INLINE_ASM
     if (comp->emit_inline_asm != NULL) {
         ASM_EMITTER(free)(comp->emit_inline_asm);
diff --git a/py/dynruntime.h b/py/dynruntime.h
index bbe093a..494ad77 100644
--- a/py/dynruntime.h
+++ b/py/dynruntime.h
@@ -73,18 +73,18 @@
 /******************************************************************************/
 // Types and objects
 
-#define MP_OBJ_NEW_QSTR(x) MP_OBJ_NEW_QSTR_ ## x
+#define MP_OBJ_NEW_QSTR(x) MP_OBJ_NEW_QSTR_##x
 
 #define mp_type_type                        (*mp_fun_table.type_type)
 #define mp_type_str                         (*mp_fun_table.type_str)
 #define mp_type_list                        (*mp_fun_table.type_list)
-#define mp_type_EOFError                    (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_EOFError)))
-#define mp_type_IndexError                  (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_IndexError)))
-#define mp_type_KeyError                    (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_KeyError)))
-#define mp_type_NotImplementedError         (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_NotImplementedError)))
-#define mp_type_RuntimeError                (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_RuntimeError)))
-#define mp_type_TypeError                   (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_TypeError)))
-#define mp_type_ValueError                  (*(mp_obj_type_t*)(mp_load_global(MP_QSTR_ValueError)))
+#define mp_type_EOFError                    (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_EOFError)))
+#define mp_type_IndexError                  (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_IndexError)))
+#define mp_type_KeyError                    (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_KeyError)))
+#define mp_type_NotImplementedError         (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_NotImplementedError)))
+#define mp_type_RuntimeError                (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_RuntimeError)))
+#define mp_type_TypeError                   (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_TypeError)))
+#define mp_type_ValueError                  (*(mp_obj_type_t *)(mp_load_global(MP_QSTR_ValueError)))
 
 #define mp_stream_read_obj                  (*mp_fun_table.stream_read_obj)
 #define mp_stream_readinto_obj              (*mp_fun_table.stream_readinto_obj)
@@ -110,7 +110,7 @@
 #define mp_obj_cast_to_native_base(o, t)    (mp_obj_cast_to_native_base_dyn((o), (t)))
 #define mp_obj_get_int(o)                   (mp_fun_table.native_from_obj(o, MP_NATIVE_TYPE_INT))
 #define mp_obj_get_int_truncated(o)         (mp_fun_table.native_from_obj(o, MP_NATIVE_TYPE_UINT))
-#define mp_obj_str_get_str(s)               ((void*)mp_fun_table.native_from_obj(s, MP_NATIVE_TYPE_PTR))
+#define mp_obj_str_get_str(s)               ((void *)mp_fun_table.native_from_obj(s, MP_NATIVE_TYPE_PTR))
 #define mp_obj_str_get_data(o, len)         (mp_obj_str_get_data_dyn((o), (len)))
 #define mp_get_buffer_raise(o, bufinfo, fl) (mp_fun_table.get_buffer_raise((o), (bufinfo), (fl)))
 #define mp_get_stream_raise(s, flags)       (mp_fun_table.get_stream_raise((s), (flags)))
@@ -119,9 +119,9 @@
 #define mp_obj_subscr(base, index, val)     (mp_fun_table.obj_subscr((base), (index), (val)))
 #define mp_obj_list_append(list, item)      (mp_fun_table.list_append((list), (item)))
 
-static inline mp_obj_t mp_obj_new_str_of_type_dyn(const mp_obj_type_t *type, const byte* data, size_t len) {
+static inline mp_obj_t mp_obj_new_str_of_type_dyn(const mp_obj_type_t *type, const byte *data, size_t len) {
     if (type == &mp_type_str) {
-        return mp_obj_new_str((const char*)data, len);
+        return mp_obj_new_str((const char *)data, len);
     } else {
         return mp_obj_new_bytes(data, len);
     }
@@ -137,7 +137,7 @@
         // This is a very simple version of mp_obj_is_subclass_fast that could be improved.
         return MP_OBJ_NULL;
     } else {
-        mp_obj_instance_t *self = (mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in);
+        mp_obj_instance_t *self = (mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in);
         return self->subobj[0];
     }
 }
@@ -177,7 +177,7 @@
     mp_raw_code_t rc; \
     rc.kind = MP_CODE_NATIVE_VIPER; \
     rc.scope_flags = 0; \
-    rc.const_table = (void*)self->const_table; \
+    rc.const_table = (void *)self->const_table; \
     (void)rc;
 
 #define MP_DYNRUNTIME_INIT_EXIT \
diff --git a/py/emit.h b/py/emit.h
index 26d027a..13bd3e9 100644
--- a/py/emit.h
+++ b/py/emit.h
@@ -99,7 +99,7 @@
 
 typedef struct _emit_method_table_t {
     #if MICROPY_DYNAMIC_COMPILER
-    emit_t *(*emit_new)(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
+    emit_t *(*emit_new)(mp_obj_t * error_slot, uint *label_slot, mp_uint_t max_num_labels);
     void (*emit_free)(emit_t *emit);
     #endif
 
@@ -188,7 +188,7 @@
 emit_t *emit_native_xtensa_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
 emit_t *emit_native_xtensawin_new(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels);
 
-void emit_bc_set_max_num_labels(emit_t* emit, mp_uint_t max_num_labels);
+void emit_bc_set_max_num_labels(emit_t *emit, mp_uint_t max_num_labels);
 
 void emit_bc_free(emit_t *emit);
 void emit_native_x64_free(emit_t *emit);
diff --git a/py/emitbc.c b/py/emitbc.c
index ee4a7d5..e90c28c 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -121,7 +121,7 @@
     }
 }
 
-STATIC void emit_write_code_info_byte(emit_t* emit, byte val) {
+STATIC void emit_write_code_info_byte(emit_t *emit, byte val) {
     *emit_get_cur_to_write_code_info(emit, 1) = val;
 }
 
@@ -230,7 +230,7 @@
 }
 #endif
 
-STATIC void emit_write_bytecode_byte_qstr(emit_t* emit, int stack_adj, byte b, qstr qst) {
+STATIC void emit_write_bytecode_byte_qstr(emit_t *emit, int stack_adj, byte b, qstr qst) {
     #if MICROPY_PERSISTENT_CODE
     assert((qst >> 16) == 0);
     mp_emit_bc_adjust_stack_size(emit, stack_adj);
@@ -252,7 +252,7 @@
     // aligns the pointer so it is friendly to GC
     emit_write_bytecode_byte(emit, stack_adj, b);
     emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(mp_obj_t));
-    mp_obj_t *c = (mp_obj_t*)emit_get_cur_to_write_bytecode(emit, sizeof(mp_obj_t));
+    mp_obj_t *c = (mp_obj_t *)emit_get_cur_to_write_bytecode(emit, sizeof(mp_obj_t));
     // Verify thar c is already uint-aligned
     assert(c == MP_ALIGN(c, sizeof(mp_obj_t)));
     *c = obj;
@@ -267,10 +267,10 @@
     #else
     // aligns the pointer so it is friendly to GC
     emit_write_bytecode_byte(emit, stack_adj, b);
-    emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(void*));
-    void **c = (void**)emit_get_cur_to_write_bytecode(emit, sizeof(void*));
+    emit->bytecode_offset = (size_t)MP_ALIGN(emit->bytecode_offset, sizeof(void *));
+    void **c = (void **)emit_get_cur_to_write_bytecode(emit, sizeof(void *));
     // Verify thar c is already uint-aligned
-    assert(c == MP_ALIGN(c, sizeof(void*)));
+    assert(c == MP_ALIGN(c, sizeof(void *)));
     *c = rc;
     #endif
     #if MICROPY_PY_SYS_SETTRACE
@@ -467,7 +467,7 @@
 }
 
 void mp_emit_bc_set_source_line(emit_t *emit, mp_uint_t source_line) {
-#if MICROPY_ENABLE_SOURCE_LINE
+    #if MICROPY_ENABLE_SOURCE_LINE
     if (MP_STATE_VM(mp_optimise_value) >= 3) {
         // If we compile with -O3, don't store line numbers.
         return;
@@ -479,10 +479,10 @@
         emit->last_source_line_offset = emit->bytecode_offset;
         emit->last_source_line = source_line;
     }
-#else
+    #else
     (void)emit;
     (void)source_line;
-#endif
+    #endif
 }
 
 void mp_emit_bc_label_assign(emit_t *emit, mp_uint_t l) {
diff --git a/py/emitglue.c b/py/emitglue.c
index d30a1e6..98320c4 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -84,17 +84,17 @@
     mp_prof_extract_prelude(code, prelude);
     #endif
 
-#ifdef DEBUG_PRINT
+    #ifdef DEBUG_PRINT
     #if !MICROPY_DEBUG_PRINTERS
     const size_t len = 0;
     #endif
     DEBUG_printf("assign byte code: code=%p len=" UINT_FMT " flags=%x\n", code, len, (uint)scope_flags);
-#endif
-#if MICROPY_DEBUG_PRINTERS
+    #endif
+    #if MICROPY_DEBUG_PRINTERS
     if (mp_verbose_flag >= 2) {
         mp_bytecode_print(rc, code, len, const_table);
     }
-#endif
+    #endif
 }
 
 #if MICROPY_EMIT_MACHINE_CODE
@@ -120,28 +120,28 @@
     rc->prelude_offset = prelude_offset;
     rc->n_obj = n_obj;
     rc->n_raw_code = n_raw_code;
-    rc->n_qstr= n_qstr;
+    rc->n_qstr = n_qstr;
     rc->qstr_link = qstr_link;
     #endif
 
-#ifdef DEBUG_PRINT
+    #ifdef DEBUG_PRINT
     DEBUG_printf("assign native: kind=%d fun=%p len=" UINT_FMT " n_pos_args=" UINT_FMT " flags=%x\n", kind, fun_data, fun_len, n_pos_args, (uint)scope_flags);
     for (mp_uint_t i = 0; i < fun_len; i++) {
         if (i > 0 && i % 16 == 0) {
             DEBUG_printf("\n");
         }
-        DEBUG_printf(" %02x", ((byte*)fun_data)[i]);
+        DEBUG_printf(" %02x", ((byte *)fun_data)[i]);
     }
     DEBUG_printf("\n");
 
-#ifdef WRITE_CODE
+    #ifdef WRITE_CODE
     FILE *fp_write_code = fopen("out-code", "wb");
     fwrite(fun_data, fun_len, 1, fp_write_code);
     fclose(fp_write_code);
-#endif
-#else
+    #endif
+    #else
     (void)fun_len;
-#endif
+    #endif
 }
 #endif
 
@@ -164,7 +164,7 @@
             fun = mp_obj_new_fun_native(def_args, def_kw_args, rc->fun_data, rc->const_table);
             // Check for a generator function, and if so change the type of the object
             if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
-                ((mp_obj_base_t*)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
+                ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_native_gen_wrap;
             }
             break;
         #endif
@@ -179,7 +179,7 @@
             fun = mp_obj_new_fun_bc(def_args, def_kw_args, rc->fun_data, rc->const_table);
             // check for generator functions and if so change the type of the object
             if ((rc->scope_flags & MP_SCOPE_FLAG_GENERATOR) != 0) {
-                ((mp_obj_base_t*)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
+                ((mp_obj_base_t *)MP_OBJ_TO_PTR(fun))->type = &mp_type_gen_wrap;
             }
 
             #if MICROPY_PY_SYS_SETTRACE
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 0f58976..358ccac 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -39,14 +39,14 @@
 // define rules with a compile function
 #define DEF_RULE(rule, comp, kind, ...) PN_##rule,
 #define DEF_RULE_NC(rule, kind, ...)
-#include "py/grammar.h"
+    #include "py/grammar.h"
 #undef DEF_RULE
 #undef DEF_RULE_NC
     PN_const_object, // special node for a constant, generic Python object
 // define rules without a compile function
 #define DEF_RULE(rule, comp, kind, ...)
 #define DEF_RULE_NC(rule, kind, ...) PN_##rule,
-#include "py/grammar.h"
+    #include "py/grammar.h"
 #undef DEF_RULE
 #undef DEF_RULE_NC
 } pn_kind_t;
@@ -131,7 +131,9 @@
     return true;
 }
 
-typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t;
+typedef struct _reg_name_t { byte reg;
+                             byte name[3];
+} reg_name_t;
 STATIC const reg_name_t reg_name_table[] = {
     {0, "r0\0"},
     {1, "r1\0"},
@@ -157,7 +159,9 @@
 };
 
 #define MAX_SPECIAL_REGISTER_NAME_LENGTH 7
-typedef struct _special_reg_name_t { byte reg; char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1]; } special_reg_name_t;
+typedef struct _special_reg_name_t { byte reg;
+                                     char name[MAX_SPECIAL_REGISTER_NAME_LENGTH + 1];
+} special_reg_name_t;
 STATIC const special_reg_name_t special_reg_name_table[] = {
     {5, "IPSR"},
     {17, "BASEPRI"},
@@ -226,8 +230,8 @@
         }
         if (regno > 31) {
             emit_inline_thumb_error_exc(emit,
-                 mp_obj_new_exception_msg_varg(&mp_type_SyntaxError,
-                       "'%s' expects at most r%d", op, 31));
+                mp_obj_new_exception_msg_varg(&mp_type_SyntaxError,
+                    "'%s' expects at most r%d", op, 31));
             return 0;
         } else {
             return regno;
@@ -235,7 +239,7 @@
     }
 malformed:
     emit_inline_thumb_error_exc(emit,
-         mp_obj_new_exception_msg_varg(&mp_type_SyntaxError,
+        mp_obj_new_exception_msg_varg(&mp_type_SyntaxError,
             "'%s' expects an FPU register", op));
     return 0;
 }
@@ -248,7 +252,7 @@
         goto bad_arg;
     }
 
-    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
     assert(MP_PARSE_NODE_STRUCT_NUM_NODES(pns) == 1); // should always be
     pn = pns->nodes[0];
 
@@ -258,10 +262,10 @@
         // set with one element
         reglist |= 1 << get_arg_reg(emit, op, pn, 15);
     } else if (MP_PARSE_NODE_IS_STRUCT(pn)) {
-        pns = (mp_parse_node_struct_t*)pn;
+        pns = (mp_parse_node_struct_t *)pn;
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == PN_dictorsetmaker) {
             assert(MP_PARSE_NODE_IS_STRUCT(pns->nodes[1])); // should succeed
-            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pns->nodes[1];
+            mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pns->nodes[1];
             if (MP_PARSE_NODE_STRUCT_KIND(pns1) == PN_dictorsetmaker_list) {
                 // set with multiple elements
 
@@ -311,11 +315,11 @@
     if (!MP_PARSE_NODE_IS_STRUCT_KIND(pn, PN_atom_bracket)) {
         goto bad_arg;
     }
-    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+    mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
     if (!MP_PARSE_NODE_IS_STRUCT_KIND(pns->nodes[0], PN_testlist_comp)) {
         goto bad_arg;
     }
-    pns = (mp_parse_node_struct_t*)pns->nodes[0];
+    pns = (mp_parse_node_struct_t *)pns->nodes[0];
     if (MP_PARSE_NODE_STRUCT_NUM_NODES(pns) != 2) {
         goto bad_arg;
     }
@@ -347,7 +351,9 @@
     return 0;
 }
 
-typedef struct _cc_name_t { byte cc; byte name[2]; } cc_name_t;
+typedef struct _cc_name_t { byte cc;
+                            byte name[2];
+} cc_name_t;
 STATIC const cc_name_t cc_name_table[] = {
     { ASM_THUMB_CC_EQ, "eq" },
     { ASM_THUMB_CC_NE, "ne" },
@@ -365,7 +371,9 @@
     { ASM_THUMB_CC_LE, "le" },
 };
 
-typedef struct _format_4_op_t { byte op; char name[3]; } format_4_op_t;
+typedef struct _format_4_op_t { byte op;
+                                char name[3];
+} format_4_op_t;
 #define X(x) (((x) >> 4) & 0xff) // only need 1 byte to distinguish these ops
 STATIC const format_4_op_t format_4_op_table[] = {
     { X(ASM_THUMB_FORMAT_4_EOR), "eor" },
@@ -387,7 +395,9 @@
 #undef X
 
 // name is actually a qstr, which should fit in 16 bits
-typedef struct _format_9_10_op_t { uint16_t op; uint16_t name; } format_9_10_op_t;
+typedef struct _format_9_10_op_t { uint16_t op;
+                                   uint16_t name;
+} format_9_10_op_t;
 #define X(x) (x)
 STATIC const format_9_10_op_t format_9_10_op_table[] = {
     { X(ASM_THUMB_FORMAT_9_LDR | ASM_THUMB_FORMAT_9_WORD_TRANSFER), MP_QSTR_ldr },
@@ -401,7 +411,9 @@
 
 #if MICROPY_EMIT_INLINE_THUMB_FLOAT
 // actual opcodes are: 0xee00 | op.hi_nibble, 0x0a00 | op.lo_nibble
-typedef struct _format_vfp_op_t { byte op; char name[3]; } format_vfp_op_t;
+typedef struct _format_vfp_op_t { byte op;
+                                  char name[3];
+} format_vfp_op_t;
 STATIC const format_vfp_op_t format_vfp_op_table[] = {
     { 0x30, "add" },
     { 0x34, "sub" },
@@ -425,7 +437,7 @@
     // "subs", RLO, RLO, I3, asm_thumb_subs_reg_reg_i3
 
     size_t op_len;
-    const char *op_str = (const char*)qstr_data(op, &op_len);
+    const char *op_str = (const char *)qstr_data(op, &op_len);
 
     #if MICROPY_EMIT_INLINE_THUMB_FLOAT
     if (op_str[0] == 'v') {
@@ -434,7 +446,7 @@
             mp_uint_t op_code = 0x0ac0, op_code_hi;
             if (op == MP_QSTR_vcmp) {
                 op_code_hi = 0xeeb4;
-                op_vfp_twoargs:;
+            op_vfp_twoargs:;
                 mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]);
                 mp_uint_t vm = get_arg_vfpreg(emit, op_str, pn_args[1]);
                 asm_thumb_op32(&emit->as,
@@ -485,7 +497,7 @@
                     0x0a10 | (r_arm << 12) | ((vm & 1) << 7));
             } else if (op == MP_QSTR_vldr) {
                 op_code_hi = 0xed90;
-                op_vldr_vstr:;
+            op_vldr_vstr:;
                 mp_uint_t vd = get_arg_vfpreg(emit, op_str, pn_args[0]);
                 mp_parse_node_t pn_base, pn_offset;
                 if (get_arg_addr(emit, op_str, pn_args[1], &pn_base, &pn_offset)) {
@@ -549,8 +561,8 @@
             mp_uint_t r = get_arg_reg(emit, op_str, pn_args[0], 15);
             asm_thumb_op16(&emit->as, 0x4700 | (r << 3));
         } else if (op_str[0] == 'b' && (op_len == 3
-                    || (op_len == 5 && op_str[3] == '_'
-                        && (op_str[4] == 'n' || (ARMV7M && op_str[4] == 'w'))))) {
+                                        || (op_len == 5 && op_str[3] == '_'
+                                            && (op_str[4] == 'n' || (ARMV7M && op_str[4] == 'w'))))) {
             mp_uint_t cc = -1;
             for (mp_uint_t i = 0; i < MP_ARRAY_SIZE(cc_name_table); i++) {
                 if (op_str[1] == cc_name_table[i].name[0] && op_str[2] == cc_name_table[i].name[1]) {
@@ -639,7 +651,7 @@
                 op_code_hi = 0xfab0;
                 op_code = 0xf080;
                 mp_uint_t rd, rm;
-                op_clz_rbit:
+            op_clz_rbit:
                 rd = get_arg_reg(emit, op_str, pn_args[0], 15);
                 rm = get_arg_reg(emit, op_str, pn_args[1], 15);
                 asm_thumb_op32(&emit->as, op_code_hi | rm, op_code | (rd << 8) | rm);
@@ -647,7 +659,7 @@
                 op_code_hi = 0xfa90;
                 op_code = 0xf0a0;
                 goto op_clz_rbit;
-            } else if (ARMV7M && op == MP_QSTR_mrs){
+            } else if (ARMV7M && op == MP_QSTR_mrs) {
                 mp_uint_t reg_dest = get_arg_reg(emit, op_str, pn_args[0], 12);
                 mp_uint_t reg_src = get_arg_special_reg(emit, op_str, pn_args[1]);
                 asm_thumb_op32(&emit->as, 0xf3ef, 0x8000 | (reg_dest << 8) | reg_src);
@@ -655,7 +667,7 @@
                 if (op == MP_QSTR_and_) {
                     op_code = ASM_THUMB_FORMAT_4_AND;
                     mp_uint_t reg_dest, reg_src;
-                    op_format_4:
+                op_format_4:
                     reg_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
                     reg_src = get_arg_reg(emit, op_str, pn_args[1], 7);
                     asm_thumb_format_4(&emit->as, op_code, reg_dest, reg_src);
@@ -676,7 +688,7 @@
             if (op == MP_QSTR_mov) {
                 op_code = ASM_THUMB_FORMAT_3_MOV;
                 mp_uint_t rlo_dest, i8_src;
-                op_format_3:
+            op_format_3:
                 rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
                 i8_src = get_arg_i(emit, op_str, pn_args[1], 0xff);
                 asm_thumb_format_3(&emit->as, op_code, rlo_dest, i8_src);
@@ -692,7 +704,7 @@
             } else if (ARMV7M && op == MP_QSTR_movw) {
                 op_code = ASM_THUMB_OP_MOVW;
                 mp_uint_t reg_dest;
-                op_movw_movt:
+            op_movw_movt:
                 reg_dest = get_arg_reg(emit, op_str, pn_args[0], 15);
                 int i_src = get_arg_i(emit, op_str, pn_args[1], 0xffff);
                 asm_thumb_mov_reg_i16(&emit->as, op_code, reg_dest, i_src);
@@ -745,7 +757,7 @@
         if (op == MP_QSTR_lsl) {
             op_code = ASM_THUMB_FORMAT_1_LSL;
             mp_uint_t rlo_dest, rlo_src, i5;
-            op_format_1:
+        op_format_1:
             rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
             rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7);
             i5 = get_arg_i(emit, op_str, pn_args[2], 0x1f);
@@ -759,7 +771,7 @@
         } else if (op == MP_QSTR_add) {
             op_code = ASM_THUMB_FORMAT_2_ADD;
             mp_uint_t rlo_dest, rlo_src;
-            op_format_2:
+        op_format_2:
             rlo_dest = get_arg_reg(emit, op_str, pn_args[0], 7);
             rlo_src = get_arg_reg(emit, op_str, pn_args[1], 7);
             int src_b;
@@ -774,7 +786,7 @@
         } else if (ARMV7M && op == MP_QSTR_sdiv) {
             op_code = 0xfb90; // sdiv high part
             mp_uint_t rd, rn, rm;
-            op_sdiv_udiv:
+        op_sdiv_udiv:
             rd = get_arg_reg(emit, op_str, pn_args[0], 15);
             rn = get_arg_reg(emit, op_str, pn_args[1], 15);
             rm = get_arg_reg(emit, op_str, pn_args[2], 15);
diff --git a/py/emitinlinextensa.c b/py/emitinlinextensa.c
index d101791..6776382 100644
--- a/py/emitinlinextensa.c
+++ b/py/emitinlinextensa.c
@@ -115,7 +115,9 @@
     return true;
 }
 
-typedef struct _reg_name_t { byte reg; byte name[3]; } reg_name_t;
+typedef struct _reg_name_t { byte reg;
+                             byte name[3];
+} reg_name_t;
 STATIC const reg_name_t reg_name_table[] = {
     {0, "a0\0"},
     {1, "a1\0"},
@@ -242,7 +244,7 @@
 
 STATIC void emit_inline_xtensa_op(emit_inline_asm_t *emit, qstr op, mp_uint_t n_args, mp_parse_node_t *pn_args) {
     size_t op_len;
-    const char *op_str = (const char*)qstr_data(op, &op_len);
+    const char *op_str = (const char *)qstr_data(op, &op_len);
 
     if (n_args == 0) {
         if (op == MP_QSTR_ret_n) {
diff --git a/py/emitnative.c b/py/emitnative.c
index da60c11..7deabe3 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -135,7 +135,7 @@
 
 #define EMIT_NATIVE_VIPER_TYPE_ERROR(emit, ...) do { \
         *emit->error_slot = mp_obj_new_exception_msg_varg(&mp_type_ViperTypeError, __VA_ARGS__); \
-    } while (0)
+} while (0)
 
 typedef enum {
     STACK_VALUE,
@@ -163,15 +163,25 @@
 
 STATIC qstr vtype_to_qstr(vtype_kind_t vtype) {
     switch (vtype) {
-        case VTYPE_PYOBJ: return MP_QSTR_object;
-        case VTYPE_BOOL: return MP_QSTR_bool;
-        case VTYPE_INT: return MP_QSTR_int;
-        case VTYPE_UINT: return MP_QSTR_uint;
-        case VTYPE_PTR: return MP_QSTR_ptr;
-        case VTYPE_PTR8: return MP_QSTR_ptr8;
-        case VTYPE_PTR16: return MP_QSTR_ptr16;
-        case VTYPE_PTR32: return MP_QSTR_ptr32;
-        case VTYPE_PTR_NONE: default: return MP_QSTR_None;
+        case VTYPE_PYOBJ:
+            return MP_QSTR_object;
+        case VTYPE_BOOL:
+            return MP_QSTR_bool;
+        case VTYPE_INT:
+            return MP_QSTR_int;
+        case VTYPE_UINT:
+            return MP_QSTR_uint;
+        case VTYPE_PTR:
+            return MP_QSTR_ptr;
+        case VTYPE_PTR8:
+            return MP_QSTR_ptr8;
+        case VTYPE_PTR16:
+            return MP_QSTR_ptr16;
+        case VTYPE_PTR32:
+            return MP_QSTR_ptr32;
+        case VTYPE_PTR_NONE:
+        default:
+            return MP_QSTR_None;
     }
 }
 
@@ -244,7 +254,7 @@
 STATIC void emit_native_global_exc_exit(emit_t *emit);
 STATIC void emit_native_load_const_obj(emit_t *emit, mp_obj_t obj);
 
-emit_t *EXPORT_FUN(new)(mp_obj_t *error_slot, uint *label_slot, mp_uint_t max_num_labels) {
+emit_t *EXPORT_FUN(new)(mp_obj_t * error_slot, uint *label_slot, mp_uint_t max_num_labels) {
     emit_t *emit = m_new0(emit_t, 1);
     emit->error_slot = error_slot;
     emit->label_slot = label_slot;
@@ -257,7 +267,7 @@
     return emit;
 }
 
-void EXPORT_FUN(free)(emit_t *emit) {
+void EXPORT_FUN(free)(emit_t * emit) {
     mp_asm_base_deinit(&emit->as->base, false);
     m_del_obj(ASM_T, emit->as);
     m_del(exc_stack_entry_t, emit->exc_stack, emit->exc_stack_alloc);
@@ -733,14 +743,14 @@
     if (emit->pass > MP_PASS_SCOPE && emit->stack_size > emit->scope->stack_size) {
         emit->scope->stack_size = emit->stack_size;
     }
-#ifdef DEBUG_PRINT
+    #ifdef DEBUG_PRINT
     DEBUG_printf("  adjust_stack; stack_size=%d+%d; stack now:", emit->stack_size - stack_size_delta, stack_size_delta);
     for (int i = 0; i < emit->stack_size; i++) {
         stack_info_t *si = &emit->stack_info[i];
         DEBUG_printf(" (v=%d k=%d %d)", si->vtype, si->kind, si->data.u_reg);
     }
     DEBUG_printf("\n");
-#endif
+    #endif
 }
 
 STATIC void emit_native_adjust_stack_size(emit_t *emit, mp_int_t delta) {
@@ -1132,8 +1142,8 @@
 
     bool is_finally = false;
     if (emit->exc_stack_size > 0) {
-       exc_stack_entry_t *e = &emit->exc_stack[emit->exc_stack_size - 1];
-       is_finally = e->is_finally && e->label == l;
+        exc_stack_entry_t *e = &emit->exc_stack[emit->exc_stack_size - 1];
+        is_finally = e->is_finally && e->label == l;
     }
 
     if (is_finally) {
@@ -2423,7 +2433,7 @@
                 asm_xtensa_setcc_reg_reg_reg(emit->as, cc & ~0x80, REG_RET, reg_rhs, REG_ARG_2);
             }
             #else
-                #error not implemented
+            #error not implemented
             #endif
             emit_post_push_reg(emit, VTYPE_BOOL, REG_RET);
         } else {
diff --git a/py/formatfloat.c b/py/formatfloat.c
index dc7fc1d..50fc0da 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -68,11 +68,20 @@
     float f;
     uint32_t u;
 };
-static inline int fp_signbit(float x) { union floatbits fb = {x}; return fb.u & FLT_SIGN_MASK; }
+static inline int fp_signbit(float x) {
+    union floatbits fb = {x};
+    return fb.u & FLT_SIGN_MASK;
+}
 #define fp_isnan(x) isnan(x)
 #define fp_isinf(x) isinf(x)
-static inline int fp_iszero(float x) { union floatbits fb = {x}; return fb.u == 0; }
-static inline int fp_isless1(float x) { union floatbits fb = {x}; return fb.u < 0x3f800000; }
+static inline int fp_iszero(float x) {
+    union floatbits fb = {x};
+    return fb.u == 0;
+}
+static inline int fp_isless1(float x) {
+    union floatbits fb = {x};
+    return fb.u < 0x3f800000;
+}
 
 #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
 
@@ -282,7 +291,7 @@
         if (fmt == 'e' && prec > (buf_remaining - FPMIN_BUF_SIZE)) {
             prec = buf_remaining - FPMIN_BUF_SIZE;
         }
-        if (fmt == 'g'){
+        if (fmt == 'g') {
             // Truncate precision to prevent buffer overflow
             if (prec + (FPMIN_BUF_SIZE - 1) > buf_remaining) {
                 prec = buf_remaining - (FPMIN_BUF_SIZE - 1);
diff --git a/py/frozenmod.c b/py/frozenmod.c
index 06d4f84..a250c02 100644
--- a/py/frozenmod.c
+++ b/py/frozenmod.c
@@ -146,7 +146,7 @@
     #if MICROPY_MODULE_FROZEN_MPY
     const mp_raw_code_t *rc = mp_find_frozen_mpy(str, len);
     if (rc != NULL) {
-        *data = (void*)rc;
+        *data = (void *)rc;
         return MP_FROZEN_MPY;
     }
     #endif
diff --git a/py/gc.c b/py/gc.c
index 092dbc7..7d159ad 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -82,7 +82,7 @@
 #define ATB_HEAD_TO_MARK(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] |= (AT_MARK << BLOCK_SHIFT(block)); } while (0)
 #define ATB_MARK_TO_HEAD(block) do { MP_STATE_MEM(gc_alloc_table_start)[(block) / BLOCKS_PER_ATB] &= (~(AT_TAIL << BLOCK_SHIFT(block))); } while (0)
 
-#define BLOCK_FROM_PTR(ptr) (((byte*)(ptr) - MP_STATE_MEM(gc_pool_start)) / BYTES_PER_BLOCK)
+#define BLOCK_FROM_PTR(ptr) (((byte *)(ptr) - MP_STATE_MEM(gc_pool_start)) / BYTES_PER_BLOCK)
 #define PTR_FROM_BLOCK(block) (((block) * BYTES_PER_BLOCK + (uintptr_t)MP_STATE_MEM(gc_pool_start)))
 #define ATB_FROM_BLOCK(bl) ((bl) / BLOCKS_PER_ATB)
 
@@ -108,43 +108,43 @@
 // TODO waste less memory; currently requires that all entries in alloc_table have a corresponding block in pool
 void gc_init(void *start, void *end) {
     // align end pointer on block boundary
-    end = (void*)((uintptr_t)end & (~(BYTES_PER_BLOCK - 1)));
-    DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, (byte*)end - (byte*)start);
+    end = (void *)((uintptr_t)end & (~(BYTES_PER_BLOCK - 1)));
+    DEBUG_printf("Initializing GC heap: %p..%p = " UINT_FMT " bytes\n", start, end, (byte *)end - (byte *)start);
 
     // calculate parameters for GC (T=total, A=alloc table, F=finaliser table, P=pool; all in bytes):
     // T = A + F + P
     //     F = A * BLOCKS_PER_ATB / BLOCKS_PER_FTB
     //     P = A * BLOCKS_PER_ATB * BYTES_PER_BLOCK
     // => T = A * (1 + BLOCKS_PER_ATB / BLOCKS_PER_FTB + BLOCKS_PER_ATB * BYTES_PER_BLOCK)
-    size_t total_byte_len = (byte*)end - (byte*)start;
-#if MICROPY_ENABLE_FINALISER
+    size_t total_byte_len = (byte *)end - (byte *)start;
+    #if MICROPY_ENABLE_FINALISER
     MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len * BITS_PER_BYTE / (BITS_PER_BYTE + BITS_PER_BYTE * BLOCKS_PER_ATB / BLOCKS_PER_FTB + BITS_PER_BYTE * BLOCKS_PER_ATB * BYTES_PER_BLOCK);
-#else
+    #else
     MP_STATE_MEM(gc_alloc_table_byte_len) = total_byte_len / (1 + BITS_PER_BYTE / 2 * BYTES_PER_BLOCK);
-#endif
+    #endif
 
-    MP_STATE_MEM(gc_alloc_table_start) = (byte*)start;
+    MP_STATE_MEM(gc_alloc_table_start) = (byte *)start;
 
-#if MICROPY_ENABLE_FINALISER
+    #if MICROPY_ENABLE_FINALISER
     size_t gc_finaliser_table_byte_len = (MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB + BLOCKS_PER_FTB - 1) / BLOCKS_PER_FTB;
     MP_STATE_MEM(gc_finaliser_table_start) = MP_STATE_MEM(gc_alloc_table_start) + MP_STATE_MEM(gc_alloc_table_byte_len);
-#endif
+    #endif
 
     size_t gc_pool_block_len = MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB;
-    MP_STATE_MEM(gc_pool_start) = (byte*)end - gc_pool_block_len * BYTES_PER_BLOCK;
+    MP_STATE_MEM(gc_pool_start) = (byte *)end - gc_pool_block_len * BYTES_PER_BLOCK;
     MP_STATE_MEM(gc_pool_end) = end;
 
-#if MICROPY_ENABLE_FINALISER
+    #if MICROPY_ENABLE_FINALISER
     assert(MP_STATE_MEM(gc_pool_start) >= MP_STATE_MEM(gc_finaliser_table_start) + gc_finaliser_table_byte_len);
-#endif
+    #endif
 
     // clear ATBs
     memset(MP_STATE_MEM(gc_alloc_table_start), 0, MP_STATE_MEM(gc_alloc_table_byte_len));
 
-#if MICROPY_ENABLE_FINALISER
+    #if MICROPY_ENABLE_FINALISER
     // clear FTBs
     memset(MP_STATE_MEM(gc_finaliser_table_start), 0, gc_finaliser_table_byte_len);
-#endif
+    #endif
 
     // set last free ATB index to start of heap
     MP_STATE_MEM(gc_last_free_atb_index) = 0;
@@ -167,9 +167,9 @@
 
     DEBUG_printf("GC layout:\n");
     DEBUG_printf("  alloc table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_alloc_table_start), MP_STATE_MEM(gc_alloc_table_byte_len), MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB);
-#if MICROPY_ENABLE_FINALISER
+    #if MICROPY_ENABLE_FINALISER
     DEBUG_printf("  finaliser table at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_finaliser_table_start), gc_finaliser_table_byte_len, gc_finaliser_table_byte_len * BLOCKS_PER_FTB);
-#endif
+    #endif
     DEBUG_printf("  pool at %p, length " UINT_FMT " bytes, " UINT_FMT " blocks\n", MP_STATE_MEM(gc_pool_start), gc_pool_block_len * BYTES_PER_BLOCK, gc_pool_block_len);
 }
 
@@ -191,9 +191,9 @@
 
 // ptr should be of type void*
 #define VERIFY_PTR(ptr) ( \
-        ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0      /* must be aligned on a block */ \
-        && ptr >= (void*)MP_STATE_MEM(gc_pool_start)     /* must be above start of pool */ \
-        && ptr < (void*)MP_STATE_MEM(gc_pool_end)        /* must be below end of pool */ \
+    ((uintptr_t)(ptr) & (BYTES_PER_BLOCK - 1)) == 0          /* must be aligned on a block */ \
+    && ptr >= (void *)MP_STATE_MEM(gc_pool_start)        /* must be above start of pool */ \
+    && ptr < (void *)MP_STATE_MEM(gc_pool_end)           /* must be below end of pool */ \
     )
 
 #ifndef TRACE_MARK
@@ -219,8 +219,8 @@
         } while (ATB_GET_KIND(block + n_blocks) == AT_TAIL);
 
         // check this block's children
-        void **ptrs = (void**)PTR_FROM_BLOCK(block);
-        for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void*); i > 0; i--, ptrs++) {
+        void **ptrs = (void **)PTR_FROM_BLOCK(block);
+        for (size_t i = n_blocks * BYTES_PER_BLOCK / sizeof(void *); i > 0; i--, ptrs++) {
             void *ptr = *ptrs;
             if (VERIFY_PTR(ptr)) {
                 // Mark and push this pointer
@@ -271,9 +271,9 @@
     for (size_t block = 0; block < MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB; block++) {
         switch (ATB_GET_KIND(block)) {
             case AT_HEAD:
-#if MICROPY_ENABLE_FINALISER
+                #if MICROPY_ENABLE_FINALISER
                 if (FTB_GET(block)) {
-                    mp_obj_base_t *obj = (mp_obj_base_t*)PTR_FROM_BLOCK(block);
+                    mp_obj_base_t *obj = (mp_obj_base_t *)PTR_FROM_BLOCK(block);
                     if (obj->type != NULL) {
                         // if the object has a type then see if it has a __del__ method
                         mp_obj_t dest[2];
@@ -292,19 +292,19 @@
                     // clear finaliser flag
                     FTB_CLEAR(block);
                 }
-#endif
+                #endif
                 free_tail = 1;
                 DEBUG_printf("gc_sweep(%p)\n", PTR_FROM_BLOCK(block));
                 #if MICROPY_PY_GC_COLLECT_RETVAL
                 MP_STATE_MEM(gc_collected)++;
                 #endif
-                // fall through to free the head
+            // fall through to free the head
 
             case AT_TAIL:
                 if (free_tail) {
                     ATB_ANY_TO_FREE(block);
                     #if CLEAR_ON_SWEEP
-                    memset((void*)PTR_FROM_BLOCK(block), 0, BYTES_PER_BLOCK);
+                    memset((void *)PTR_FROM_BLOCK(block), 0, BYTES_PER_BLOCK);
                     #endif
                 }
                 break;
@@ -328,15 +328,15 @@
     // Trace root pointers.  This relies on the root pointers being organised
     // correctly in the mp_state_ctx structure.  We scan nlr_top, dict_locals,
     // dict_globals, then the root pointer section of mp_state_vm.
-    void **ptrs = (void**)(void*)&mp_state_ctx;
+    void **ptrs = (void **)(void *)&mp_state_ctx;
     size_t root_start = offsetof(mp_state_ctx_t, thread.dict_locals);
     size_t root_end = offsetof(mp_state_ctx_t, vm.qstr_last_chunk);
-    gc_collect_root(ptrs + root_start / sizeof(void*), (root_end - root_start) / sizeof(void*));
+    gc_collect_root(ptrs + root_start / sizeof(void *), (root_end - root_start) / sizeof(void *));
 
     #if MICROPY_ENABLE_PYSTACK
     // Trace root pointers from the Python stack.
-    ptrs = (void**)(void*)MP_STATE_THREAD(pystack_start);
-    gc_collect_root(ptrs, (MP_STATE_THREAD(pystack_cur) - MP_STATE_THREAD(pystack_start)) / sizeof(void*));
+    ptrs = (void **)(void *)MP_STATE_THREAD(pystack_start);
+    gc_collect_root(ptrs, (MP_STATE_THREAD(pystack_cur) - MP_STATE_THREAD(pystack_start)) / sizeof(void *));
     #endif
 }
 
@@ -518,7 +518,7 @@
 
     // get pointer to first block
     // we must create this pointer before unlocking the GC so a collection can find it
-    void *ret_ptr = (void*)(MP_STATE_MEM(gc_pool_start) + start_block * BYTES_PER_BLOCK);
+    void *ret_ptr = (void *)(MP_STATE_MEM(gc_pool_start) + start_block * BYTES_PER_BLOCK);
     DEBUG_printf("gc_alloc(%p)\n", ret_ptr);
 
     #if MICROPY_GC_ALLOC_THRESHOLD
@@ -529,20 +529,20 @@
 
     #if MICROPY_GC_CONSERVATIVE_CLEAR
     // be conservative and zero out all the newly allocated blocks
-    memset((byte*)ret_ptr, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK);
+    memset((byte *)ret_ptr, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK);
     #else
     // zero out the additional bytes of the newly allocated blocks
     // This is needed because the blocks may have previously held pointers
     // to the heap and will not be set to something else if the caller
     // doesn't actually use the entire block.  As such they will continue
     // to point to the heap and may prevent other blocks from being reclaimed.
-    memset((byte*)ret_ptr + n_bytes, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK - n_bytes);
+    memset((byte *)ret_ptr + n_bytes, 0, (end_block - start_block + 1) * BYTES_PER_BLOCK - n_bytes);
     #endif
 
     #if MICROPY_ENABLE_FINALISER
     if (has_finaliser) {
         // clear type pointer in case it is never set
-        ((mp_obj_base_t*)ret_ptr)->type = NULL;
+        ((mp_obj_base_t *)ret_ptr)->type = NULL;
         // set mp_obj flag only if it has a finaliser
         GC_ENTER();
         FTB_SET(start_block);
@@ -643,11 +643,11 @@
         if (ptr == NULL) {
             has_finaliser = false;
         } else {
-#if MICROPY_ENABLE_FINALISER
+            #if MICROPY_ENABLE_FINALISER
             has_finaliser = FTB_GET(BLOCK_FROM_PTR((mp_uint_t)ptr));
-#else
+            #else
             has_finaliser = false;
-#endif
+            #endif
         }
         void *ptr2 = gc_alloc(n_bytes, has_finaliser);
         if (ptr2 == NULL) {
@@ -696,7 +696,7 @@
     // free blocks to satisfy the realloc.  Note that we need to compute the
     // total size of the existing memory chunk so we can correctly and
     // efficiently shrink it (see below for shrinking code).
-    size_t n_free   = 0;
+    size_t n_free = 0;
     size_t n_blocks = 1; // counting HEAD block
     size_t max_block = MP_STATE_MEM(gc_alloc_table_byte_len) * BLOCKS_PER_ATB;
     for (size_t bl = block + n_blocks; bl < max_block; bl++) {
@@ -755,10 +755,10 @@
 
         #if MICROPY_GC_CONSERVATIVE_CLEAR
         // be conservative and zero out all the newly allocated blocks
-        memset((byte*)ptr_in + n_blocks * BYTES_PER_BLOCK, 0, (new_blocks - n_blocks) * BYTES_PER_BLOCK);
+        memset((byte *)ptr_in + n_blocks * BYTES_PER_BLOCK, 0, (new_blocks - n_blocks) * BYTES_PER_BLOCK);
         #else
         // zero out the additional bytes of the newly allocated blocks (see comment above in gc_alloc)
-        memset((byte*)ptr_in + n_bytes, 0, new_blocks * BYTES_PER_BLOCK - n_bytes);
+        memset((byte *)ptr_in + n_bytes, 0, new_blocks * BYTES_PER_BLOCK - n_bytes);
         #endif
 
         #if EXTENSIVE_HEAP_PROFILING
@@ -802,7 +802,7 @@
     mp_printf(&mp_plat_print, "GC: total: %u, used: %u, free: %u\n",
         (uint)info.total, (uint)info.used, (uint)info.free);
     mp_printf(&mp_plat_print, " No. of 1-blocks: %u, 2-blocks: %u, max blk sz: %u, max free sz: %u\n",
-           (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block, (uint)info.max_free);
+        (uint)info.num_1block, (uint)info.num_2block, (uint)info.max_block, (uint)info.max_free);
 }
 
 void gc_dump_alloc_table(void) {
@@ -839,7 +839,9 @@
         }
         int c = ' ';
         switch (ATB_GET_KIND(bl)) {
-            case AT_FREE: c = '.'; break;
+            case AT_FREE:
+                c = '.';
+                break;
             /* this prints out if the object is reachable from BSS or STACK (for unix only)
             case AT_HEAD: {
                 c = 'h';
@@ -868,35 +870,48 @@
             */
             /* this prints the uPy object type of the head block */
             case AT_HEAD: {
-                void **ptr = (void**)(MP_STATE_MEM(gc_pool_start) + bl * BYTES_PER_BLOCK);
-                if (*ptr == &mp_type_tuple) { c = 'T'; }
-                else if (*ptr == &mp_type_list) { c = 'L'; }
-                else if (*ptr == &mp_type_dict) { c = 'D'; }
-                else if (*ptr == &mp_type_str || *ptr == &mp_type_bytes) { c = 'S'; }
+                void **ptr = (void **)(MP_STATE_MEM(gc_pool_start) + bl * BYTES_PER_BLOCK);
+                if (*ptr == &mp_type_tuple) {
+                    c = 'T';
+                } else if (*ptr == &mp_type_list) {
+                    c = 'L';
+                } else if (*ptr == &mp_type_dict) {
+                    c = 'D';
+                } else if (*ptr == &mp_type_str || *ptr == &mp_type_bytes) {
+                    c = 'S';
+                }
                 #if MICROPY_PY_BUILTINS_BYTEARRAY
-                else if (*ptr == &mp_type_bytearray) { c = 'A'; }
+                else if (*ptr == &mp_type_bytearray) {
+                    c = 'A';
+                }
                 #endif
                 #if MICROPY_PY_ARRAY
-                else if (*ptr == &mp_type_array) { c = 'A'; }
+                else if (*ptr == &mp_type_array) {
+                    c = 'A';
+                }
                 #endif
                 #if MICROPY_PY_BUILTINS_FLOAT
-                else if (*ptr == &mp_type_float) { c = 'F'; }
+                else if (*ptr == &mp_type_float) {
+                    c = 'F';
+                }
                 #endif
-                else if (*ptr == &mp_type_fun_bc) { c = 'B'; }
-                else if (*ptr == &mp_type_module) { c = 'M'; }
-                else {
+                else if (*ptr == &mp_type_fun_bc) {
+                    c = 'B';
+                } else if (*ptr == &mp_type_module) {
+                    c = 'M';
+                } else {
                     c = 'h';
                     #if 0
                     // This code prints "Q" for qstr-pool data, and "q" for qstr-str
                     // data.  It can be useful to see how qstrs are being allocated,
                     // but is disabled by default because it is very slow.
                     for (qstr_pool_t *pool = MP_STATE_VM(last_pool); c == 'h' && pool != NULL; pool = pool->prev) {
-                        if ((qstr_pool_t*)ptr == pool) {
+                        if ((qstr_pool_t *)ptr == pool) {
                             c = 'Q';
                             break;
                         }
                         for (const byte **q = pool->qstrs, **q_top = pool->qstrs + pool->len; q < q_top; q++) {
-                            if ((const byte*)ptr == *q) {
+                            if ((const byte *)ptr == *q) {
                                 c = 'q';
                                 break;
                             }
@@ -906,8 +921,12 @@
                 }
                 break;
             }
-            case AT_TAIL: c = '='; break;
-            case AT_MARK: c = 'm'; break;
+            case AT_TAIL:
+                c = '=';
+                break;
+            case AT_MARK:
+                c = 'm';
+                break;
         }
         mp_printf(&mp_plat_print, "%c", c);
     }
@@ -933,7 +952,7 @@
         p2[1] = p;
         ptrs[0] = p2;
     }
-    for (int i = 0; i < 25; i+=2) {
+    for (int i = 0; i < 25; i += 2) {
         mp_uint_t *p = gc_alloc(i, false);
         printf("p=%p\n", p);
         if (i & 3) {
@@ -945,7 +964,7 @@
     gc_dump_alloc_table();
     printf("Starting GC...\n");
     gc_collect_start();
-    gc_collect_root(ptrs, sizeof(ptrs) / sizeof(void*));
+    gc_collect_root(ptrs, sizeof(ptrs) / sizeof(void *));
     gc_collect_end();
     printf("After GC:\n");
     gc_dump_alloc_table();
diff --git a/py/lexer.c b/py/lexer.c
index 5f8adda..73ff5ec 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -105,9 +105,9 @@
 
 STATIC bool is_string_or_bytes(mp_lexer_t *lex) {
     return is_char_or(lex, '\'', '\"')
-        || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"'))
-        || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r'))
-            && is_char_following_following_or(lex, '\'', '\"'));
+           || (is_char_or3(lex, 'r', 'u', 'b') && is_char_following_or(lex, '\'', '\"'))
+           || ((is_char_and(lex, 'r', 'b') || is_char_and(lex, 'b', 'r'))
+               && is_char_following_following_or(lex, '\'', '\"'));
 }
 
 // to easily parse utf-8 identifiers we allow any raw byte with high bit set
@@ -307,17 +307,36 @@
                     switch (c) {
                         // note: "c" can never be MP_LEXER_EOF because next_char
                         // always inserts a newline at the end of the input stream
-                        case '\n': c = MP_LEXER_EOF; break; // backslash escape the newline, just ignore it
-                        case '\\': break;
-                        case '\'': break;
-                        case '"': break;
-                        case 'a': c = 0x07; break;
-                        case 'b': c = 0x08; break;
-                        case 't': c = 0x09; break;
-                        case 'n': c = 0x0a; break;
-                        case 'v': c = 0x0b; break;
-                        case 'f': c = 0x0c; break;
-                        case 'r': c = 0x0d; break;
+                        case '\n':
+                            c = MP_LEXER_EOF;
+                            break;                          // backslash escape the newline, just ignore it
+                        case '\\':
+                            break;
+                        case '\'':
+                            break;
+                        case '"':
+                            break;
+                        case 'a':
+                            c = 0x07;
+                            break;
+                        case 'b':
+                            c = 0x08;
+                            break;
+                        case 't':
+                            c = 0x09;
+                            break;
+                        case 'n':
+                            c = 0x0a;
+                            break;
+                        case 'v':
+                            c = 0x0b;
+                            break;
+                        case 'f':
+                            c = 0x0c;
+                            break;
+                        case 'r':
+                            c = 0x0d;
+                            break;
                         case 'u':
                         case 'U':
                             if (lex->tok_kind == MP_TOKEN_BYTES) {
@@ -325,9 +344,8 @@
                                 vstr_add_char(&lex->vstr, '\\');
                                 break;
                             }
-                            // Otherwise fall through.
-                        case 'x':
-                        {
+                        // Otherwise fall through.
+                        case 'x': {
                             mp_uint_t num = 0;
                             if (!get_hex(lex, (c == 'x' ? 2 : c == 'u' ? 4 : 8), &num)) {
                                 // not enough hex chars for escape sequence
@@ -707,7 +725,7 @@
 
 mp_lexer_t *mp_lexer_new_from_str_len(qstr src_name, const char *str, size_t len, size_t free_len) {
     mp_reader_t reader;
-    mp_reader_new_mem(&reader, (const byte*)str, len, free_len);
+    mp_reader_new_mem(&reader, (const byte *)str, len, free_len);
     return mp_lexer_new(src_name, reader);
 }
 
diff --git a/py/makemoduledefs.py b/py/makemoduledefs.py
index f17b0e3..d718da6 100644
--- a/py/makemoduledefs.py
+++ b/py/makemoduledefs.py
@@ -13,10 +13,7 @@
 import argparse
 
 
-pattern = re.compile(
-    r"[\n;]\s*MP_REGISTER_MODULE\((.*?),\s*(.*?),\s*(.*?)\);",
-    flags=re.DOTALL
-)
+pattern = re.compile(r"[\n;]\s*MP_REGISTER_MODULE\((.*?),\s*(.*?),\s*(.*?)\);", flags=re.DOTALL)
 
 
 def find_c_file(obj_file, vpath):
@@ -28,7 +25,7 @@
     """
     c_file = None
     relative_c_file = os.path.splitext(obj_file)[0] + ".c"
-    relative_c_file = relative_c_file.lstrip('/\\')
+    relative_c_file = relative_c_file.lstrip("/\\")
     for p in vpath:
         possible_c_file = os.path.join(p, relative_c_file)
         if os.path.exists(possible_c_file):
@@ -50,7 +47,7 @@
         # No c file to match the object file, skip
         return set()
 
-    with io.open(c_file, encoding='utf-8') as c_file_obj:
+    with io.open(c_file, encoding="utf-8") as c_file_obj:
         return set(re.findall(pattern, c_file_obj.read()))
 
 
@@ -67,15 +64,20 @@
     for module_name, obj_module, enabled_define in modules:
         mod_def = "MODULE_DEF_{}".format(module_name.upper())
         mod_defs.append(mod_def)
-        print((
-            "#if ({enabled_define})\n"
-            "    extern const struct _mp_obj_module_t {obj_module};\n"
-            "    #define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n"
-            "#else\n"
-            "    #define {mod_def}\n"
-            "#endif\n"
-            ).format(module_name=module_name, obj_module=obj_module,
-                     enabled_define=enabled_define, mod_def=mod_def)
+        print(
+            (
+                "#if ({enabled_define})\n"
+                "    extern const struct _mp_obj_module_t {obj_module};\n"
+                "    #define {mod_def} {{ MP_ROM_QSTR({module_name}), MP_ROM_PTR(&{obj_module}) }},\n"
+                "#else\n"
+                "    #define {mod_def}\n"
+                "#endif\n"
+            ).format(
+                module_name=module_name,
+                obj_module=obj_module,
+                enabled_define=enabled_define,
+                mod_def=mod_def,
+            )
         )
 
     print("\n#define MICROPY_REGISTERED_MODULES \\")
@@ -88,13 +90,13 @@
 
 def main():
     parser = argparse.ArgumentParser()
-    parser.add_argument("--vpath", default=".",
-                        help="comma separated list of folders to search for c files in")
-    parser.add_argument("files", nargs="*",
-                        help="list of c files to search")
+    parser.add_argument(
+        "--vpath", default=".", help="comma separated list of folders to search for c files in"
+    )
+    parser.add_argument("files", nargs="*", help="list of c files to search")
     args = parser.parse_args()
 
-    vpath = [p.strip() for p in args.vpath.split(',')]
+    vpath = [p.strip() for p in args.vpath.split(",")]
 
     modules = set()
     for obj_file in args.files:
@@ -104,5 +106,5 @@
     generate_module_table_header(sorted(modules))
 
 
-if __name__ == '__main__':
+if __name__ == "__main__":
     main()
diff --git a/py/makeqstrdata.py b/py/makeqstrdata.py
index 7799be0..403c406 100644
--- a/py/makeqstrdata.py
+++ b/py/makeqstrdata.py
@@ -13,49 +13,50 @@
 #   - iterating through bytes is different
 #   - codepoint2name lives in a different module
 import platform
-if platform.python_version_tuple()[0] == '2':
+
+if platform.python_version_tuple()[0] == "2":
     bytes_cons = lambda val, enc=None: bytearray(val)
     from htmlentitydefs import codepoint2name
-elif platform.python_version_tuple()[0] == '3':
+elif platform.python_version_tuple()[0] == "3":
     bytes_cons = bytes
     from html.entities import codepoint2name
 # end compatibility code
 
-codepoint2name[ord('-')] = 'hyphen';
+codepoint2name[ord("-")] = "hyphen"
 
 # add some custom names to map characters that aren't in HTML
-codepoint2name[ord(' ')] = 'space'
-codepoint2name[ord('\'')] = 'squot'
-codepoint2name[ord(',')] = 'comma'
-codepoint2name[ord('.')] = 'dot'
-codepoint2name[ord(':')] = 'colon'
-codepoint2name[ord(';')] = 'semicolon'
-codepoint2name[ord('/')] = 'slash'
-codepoint2name[ord('%')] = 'percent'
-codepoint2name[ord('#')] = 'hash'
-codepoint2name[ord('(')] = 'paren_open'
-codepoint2name[ord(')')] = 'paren_close'
-codepoint2name[ord('[')] = 'bracket_open'
-codepoint2name[ord(']')] = 'bracket_close'
-codepoint2name[ord('{')] = 'brace_open'
-codepoint2name[ord('}')] = 'brace_close'
-codepoint2name[ord('*')] = 'star'
-codepoint2name[ord('!')] = 'bang'
-codepoint2name[ord('\\')] = 'backslash'
-codepoint2name[ord('+')] = 'plus'
-codepoint2name[ord('$')] = 'dollar'
-codepoint2name[ord('=')] = 'equals'
-codepoint2name[ord('?')] = 'question'
-codepoint2name[ord('@')] = 'at_sign'
-codepoint2name[ord('^')] = 'caret'
-codepoint2name[ord('|')] = 'pipe'
-codepoint2name[ord('~')] = 'tilde'
+codepoint2name[ord(" ")] = "space"
+codepoint2name[ord("'")] = "squot"
+codepoint2name[ord(",")] = "comma"
+codepoint2name[ord(".")] = "dot"
+codepoint2name[ord(":")] = "colon"
+codepoint2name[ord(";")] = "semicolon"
+codepoint2name[ord("/")] = "slash"
+codepoint2name[ord("%")] = "percent"
+codepoint2name[ord("#")] = "hash"
+codepoint2name[ord("(")] = "paren_open"
+codepoint2name[ord(")")] = "paren_close"
+codepoint2name[ord("[")] = "bracket_open"
+codepoint2name[ord("]")] = "bracket_close"
+codepoint2name[ord("{")] = "brace_open"
+codepoint2name[ord("}")] = "brace_close"
+codepoint2name[ord("*")] = "star"
+codepoint2name[ord("!")] = "bang"
+codepoint2name[ord("\\")] = "backslash"
+codepoint2name[ord("+")] = "plus"
+codepoint2name[ord("$")] = "dollar"
+codepoint2name[ord("=")] = "equals"
+codepoint2name[ord("?")] = "question"
+codepoint2name[ord("@")] = "at_sign"
+codepoint2name[ord("^")] = "caret"
+codepoint2name[ord("|")] = "pipe"
+codepoint2name[ord("~")] = "tilde"
 
 # static qstrs, should be sorted
 
 static_qstr_list = [
     "",
-    "__dir__", # Put __dir__ after empty qstr for builtin dir() to work
+    "__dir__",  # Put __dir__ after empty qstr for builtin dir() to work
     "\n",
     " ",
     "*",
@@ -229,15 +230,18 @@
     # Make sure that valid hash is never zero, zero means "hash not computed"
     return (hash & ((1 << (8 * bytes_hash)) - 1)) or 1
 
+
 def qstr_escape(qst):
     def esc_char(m):
         c = ord(m.group(0))
         try:
             name = codepoint2name[c]
         except KeyError:
-            name = '0x%02x' % c
-        return "_" + name + '_'
-    return re.sub(r'[^A-Za-z0-9_]', esc_char, qst)
+            name = "0x%02x" % c
+        return "_" + name + "_"
+
+    return re.sub(r"[^A-Za-z0-9_]", esc_char, qst)
+
 
 def parse_input_headers(infiles):
     qcfgs = {}
@@ -257,22 +261,22 @@
 
     # read the qstrs in from the input files
     for infile in infiles:
-        with open(infile, 'rt') as f:
+        with open(infile, "rt") as f:
             for line in f:
                 line = line.strip()
 
                 # is this a config line?
-                match = re.match(r'^QCFG\((.+), (.+)\)', line)
+                match = re.match(r"^QCFG\((.+), (.+)\)", line)
                 if match:
                     value = match.group(2)
-                    if value[0] == '(' and value[-1] == ')':
+                    if value[0] == "(" and value[-1] == ")":
                         # strip parenthesis from config value
                         value = value[1:-1]
                     qcfgs[match.group(1)] = value
                     continue
 
                 # is this a QSTR line?
-                match = re.match(r'^Q\((.*)\)$', line)
+                match = re.match(r"^Q\((.*)\)$", line)
                 if not match:
                     continue
 
@@ -280,10 +284,10 @@
                 qstr = match.group(1)
 
                 # special cases to specify control characters
-                if qstr == '\\n':
-                    qstr = '\n'
-                elif qstr == '\\r\\n':
-                    qstr = '\r\n'
+                if qstr == "\\n":
+                    qstr = "\n"
+                elif qstr == "\\r\\n":
+                    qstr = "\r\n"
 
                 # work out the corresponding qstr name
                 ident = qstr_escape(qstr)
@@ -312,43 +316,54 @@
 
     return qcfgs, qstrs
 
+
 def make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr):
-    qbytes = bytes_cons(qstr, 'utf8')
+    qbytes = bytes_cons(qstr, "utf8")
     qlen = len(qbytes)
     qhash = compute_hash(qbytes, cfg_bytes_hash)
-    if all(32 <= ord(c) <= 126 and c != '\\' and c != '"' for c in qstr):
+    if all(32 <= ord(c) <= 126 and c != "\\" and c != '"' for c in qstr):
         # qstr is all printable ASCII so render it as-is (for easier debugging)
         qdata = qstr
     else:
         # qstr contains non-printable codes so render entire thing as hex pairs
-        qdata = ''.join(('\\x%02x' % b) for b in qbytes)
+        qdata = "".join(("\\x%02x" % b) for b in qbytes)
     if qlen >= (1 << (8 * cfg_bytes_len)):
-        print('qstr is too long:', qstr)
+        print("qstr is too long:", qstr)
         assert False
-    qlen_str = ('\\x%02x' * cfg_bytes_len) % tuple(((qlen >> (8 * i)) & 0xff) for i in range(cfg_bytes_len))
-    qhash_str = ('\\x%02x' * cfg_bytes_hash) % tuple(((qhash >> (8 * i)) & 0xff) for i in range(cfg_bytes_hash))
+    qlen_str = ("\\x%02x" * cfg_bytes_len) % tuple(
+        ((qlen >> (8 * i)) & 0xFF) for i in range(cfg_bytes_len)
+    )
+    qhash_str = ("\\x%02x" * cfg_bytes_hash) % tuple(
+        ((qhash >> (8 * i)) & 0xFF) for i in range(cfg_bytes_hash)
+    )
     return '(const byte*)"%s%s" "%s"' % (qhash_str, qlen_str, qdata)
 
+
 def print_qstr_data(qcfgs, qstrs):
     # get config variables
-    cfg_bytes_len = int(qcfgs['BYTES_IN_LEN'])
-    cfg_bytes_hash = int(qcfgs['BYTES_IN_HASH'])
+    cfg_bytes_len = int(qcfgs["BYTES_IN_LEN"])
+    cfg_bytes_hash = int(qcfgs["BYTES_IN_HASH"])
 
     # print out the starter of the generated C header file
-    print('// This file was automatically generated by makeqstrdata.py')
-    print('')
+    print("// This file was automatically generated by makeqstrdata.py")
+    print("")
 
     # add NULL qstr with no hash or data
-    print('QDEF(MP_QSTRnull, (const byte*)"%s%s" "")' % ('\\x00' * cfg_bytes_hash, '\\x00' * cfg_bytes_len))
+    print(
+        'QDEF(MP_QSTRnull, (const byte*)"%s%s" "")'
+        % ("\\x00" * cfg_bytes_hash, "\\x00" * cfg_bytes_len)
+    )
 
     # go through each qstr and print it out
     for order, ident, qstr in sorted(qstrs.values(), key=lambda x: x[0]):
         qbytes = make_bytes(cfg_bytes_len, cfg_bytes_hash, qstr)
-        print('QDEF(MP_QSTR_%s, %s)' % (ident, qbytes))
+        print("QDEF(MP_QSTR_%s, %s)" % (ident, qbytes))
+
 
 def do_work(infiles):
     qcfgs, qstrs = parse_input_headers(infiles)
     print_qstr_data(qcfgs, qstrs)
 
+
 if __name__ == "__main__":
     do_work(sys.argv[1:])
diff --git a/py/makeqstrdefs.py b/py/makeqstrdefs.py
index 209e7a1..03ea1af 100644
--- a/py/makeqstrdefs.py
+++ b/py/makeqstrdefs.py
@@ -20,16 +20,17 @@
         with open(args.output_dir + "/" + fname + ".qstr", "w") as f:
             f.write("\n".join(output) + "\n")
 
+
 def process_file(f):
     re_line = re.compile(r"#[line]*\s\d+\s\"([^\"]+)\"")
-    re_qstr = re.compile(r'MP_QSTR_[_a-zA-Z0-9]+')
+    re_qstr = re.compile(r"MP_QSTR_[_a-zA-Z0-9]+")
     output = []
     last_fname = None
     for line in f:
         if line.isspace():
             continue
         # match gcc-like output (# n "file") and msvc-like output (#line n "file")
-        if line.startswith(('# ', '#line')):
+        if line.startswith(("# ", "#line")):
             m = re_line.match(line)
             assert m is not None
             fname = m.group(1)
@@ -41,8 +42,8 @@
                 last_fname = fname
             continue
         for match in re_qstr.findall(line):
-            name = match.replace('MP_QSTR_', '')
-            output.append('Q(' + name + ')')
+            name = match.replace("MP_QSTR_", "")
+            output.append("Q(" + name + ")")
 
     write_out(last_fname, output)
     return ""
@@ -51,6 +52,7 @@
 def cat_together():
     import glob
     import hashlib
+
     hasher = hashlib.md5()
     all_lines = []
     outf = open(args.output_dir + "/out", "wb")
@@ -64,7 +66,7 @@
     outf.close()
     hasher.update(all_lines)
     new_hash = hasher.hexdigest()
-    #print(new_hash)
+    # print(new_hash)
     old_hash = None
     try:
         with open(args.output_file + ".hash") as f:
@@ -87,11 +89,12 @@
 
 if __name__ == "__main__":
     if len(sys.argv) != 5:
-        print('usage: %s command input_filename output_dir output_file' % sys.argv[0])
+        print("usage: %s command input_filename output_dir output_file" % sys.argv[0])
         sys.exit(2)
 
     class Args:
         pass
+
     args = Args()
     args.command = sys.argv[1]
     args.input_filename = sys.argv[2]
@@ -104,7 +107,7 @@
         pass
 
     if args.command == "split":
-        with io.open(args.input_filename, encoding='utf-8') as infile:
+        with io.open(args.input_filename, encoding="utf-8") as infile:
             process_file(infile)
 
     if args.command == "cat":
diff --git a/py/makeversionhdr.py b/py/makeversionhdr.py
index 2ab99d8..567b3b8 100644
--- a/py/makeversionhdr.py
+++ b/py/makeversionhdr.py
@@ -11,6 +11,7 @@
 import datetime
 import subprocess
 
+
 def get_version_info_from_git():
     # Python 2.6 doesn't have check_output, so check for that
     try:
@@ -21,7 +22,11 @@
 
     # Note: git describe doesn't work if no tag is available
     try:
-        git_tag = subprocess.check_output(["git", "describe", "--dirty", "--always"], stderr=subprocess.STDOUT, universal_newlines=True).strip()
+        git_tag = subprocess.check_output(
+            ["git", "describe", "--dirty", "--always"],
+            stderr=subprocess.STDOUT,
+            universal_newlines=True,
+        ).strip()
     except subprocess.CalledProcessError as er:
         if er.returncode == 128:
             # git exit code of 128 means no repository found
@@ -30,7 +35,11 @@
     except OSError:
         return None
     try:
-        git_hash = subprocess.check_output(["git", "rev-parse", "--short", "HEAD"], stderr=subprocess.STDOUT, universal_newlines=True).strip()
+        git_hash = subprocess.check_output(
+            ["git", "rev-parse", "--short", "HEAD"],
+            stderr=subprocess.STDOUT,
+            universal_newlines=True,
+        ).strip()
     except subprocess.CalledProcessError:
         git_hash = "unknown"
     except OSError:
@@ -38,9 +47,13 @@
 
     try:
         # Check if there are any modified files.
-        subprocess.check_call(["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], stderr=subprocess.STDOUT)
+        subprocess.check_call(
+            ["git", "diff", "--no-ext-diff", "--quiet", "--exit-code"], stderr=subprocess.STDOUT
+        )
         # Check if there are any staged files.
-        subprocess.check_call(["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], stderr=subprocess.STDOUT)
+        subprocess.check_call(
+            ["git", "diff-index", "--cached", "--quiet", "HEAD", "--"], stderr=subprocess.STDOUT
+        )
     except subprocess.CalledProcessError:
         git_hash += "-dirty"
     except OSError:
@@ -48,6 +61,7 @@
 
     return git_tag, git_hash
 
+
 def get_version_info_from_docs_conf():
     with open(os.path.join(os.path.dirname(sys.argv[0]), "..", "docs", "conf.py")) as f:
         for line in f:
@@ -57,6 +71,7 @@
                 return git_tag, "<no hash>"
     return None
 
+
 def make_version_header(filename):
     # Get version info using git, with fallback to docs/conf.py
     info = get_version_info_from_git()
@@ -71,12 +86,16 @@
 #define MICROPY_GIT_TAG "%s"
 #define MICROPY_GIT_HASH "%s"
 #define MICROPY_BUILD_DATE "%s"
-""" % (git_tag, git_hash, datetime.date.today().strftime("%Y-%m-%d"))
+""" % (
+        git_tag,
+        git_hash,
+        datetime.date.today().strftime("%Y-%m-%d"),
+    )
 
     # Check if the file contents changed from last time
     write_file = True
     if os.path.isfile(filename):
-        with open(filename, 'r') as f:
+        with open(filename, "r") as f:
             existing_data = f.read()
         if existing_data == file_data:
             write_file = False
@@ -84,8 +103,9 @@
     # Only write the file if we need to
     if write_file:
         print("GEN %s" % filename)
-        with open(filename, 'w') as f:
+        with open(filename, "w") as f:
             f.write(file_data)
 
+
 if __name__ == "__main__":
     make_version_header(sys.argv[1])
diff --git a/py/malloc.c b/py/malloc.c
index f5d82b4..c775d5b 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -87,22 +87,22 @@
     if (ptr == NULL && num_bytes != 0) {
         m_malloc_fail(num_bytes);
     }
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     MP_STATE_MEM(total_bytes_allocated) += num_bytes;
     MP_STATE_MEM(current_bytes_allocated) += num_bytes;
     UPDATE_PEAK();
-#endif
+    #endif
     DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
     return ptr;
 }
 
 void *m_malloc_maybe(size_t num_bytes) {
     void *ptr = malloc(num_bytes);
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     MP_STATE_MEM(total_bytes_allocated) += num_bytes;
     MP_STATE_MEM(current_bytes_allocated) += num_bytes;
     UPDATE_PEAK();
-#endif
+    #endif
     DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
     return ptr;
 }
@@ -113,11 +113,11 @@
     if (ptr == NULL && num_bytes != 0) {
         m_malloc_fail(num_bytes);
     }
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     MP_STATE_MEM(total_bytes_allocated) += num_bytes;
     MP_STATE_MEM(current_bytes_allocated) += num_bytes;
     UPDATE_PEAK();
-#endif
+    #endif
     DEBUG_printf("malloc %d : %p\n", num_bytes, ptr);
     return ptr;
 }
@@ -142,7 +142,7 @@
     if (new_ptr == NULL && new_num_bytes != 0) {
         m_malloc_fail(new_num_bytes);
     }
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     // At first thought, "Total bytes allocated" should only grow,
     // after all, it's *total*. But consider for example 2K block
     // shrunk to 1K and then grown to 2K again. It's still 2K
@@ -152,7 +152,7 @@
     MP_STATE_MEM(total_bytes_allocated) += diff;
     MP_STATE_MEM(current_bytes_allocated) += diff;
     UPDATE_PEAK();
-#endif
+    #endif
     #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
     #else
@@ -168,7 +168,7 @@
 #endif
 {
     void *new_ptr = realloc_ext(ptr, new_num_bytes, allow_move);
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     // At first thought, "Total bytes allocated" should only grow,
     // after all, it's *total*. But consider for example 2K block
     // shrunk to 1K and then grown to 2K again. It's still 2K
@@ -181,7 +181,7 @@
         MP_STATE_MEM(current_bytes_allocated) += diff;
         UPDATE_PEAK();
     }
-#endif
+    #endif
     #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("realloc %p, %d, %d : %p\n", ptr, old_num_bytes, new_num_bytes, new_ptr);
     #else
@@ -197,9 +197,9 @@
 #endif
 {
     free(ptr);
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     MP_STATE_MEM(current_bytes_allocated) -= num_bytes;
-#endif
+    #endif
     #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
     DEBUG_printf("free %p, %d\n", ptr, num_bytes);
     #else
diff --git a/py/map.c b/py/map.c
index 5f3c6e5..2570941 100644
--- a/py/map.c
+++ b/py/map.c
@@ -96,7 +96,7 @@
     map->all_keys_are_qstrs = 1;
     map->is_fixed = 1;
     map->is_ordered = 1;
-    map->table = (mp_map_elem_t*)table;
+    map->table = (mp_map_elem_t *)table;
 }
 
 // Differentiate from mp_map_clear() - semantics is different
diff --git a/py/misc.h b/py/misc.h
index 50feaf7..eafcef9 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -57,28 +57,28 @@
 
 // TODO make a lazy m_renew that can increase by a smaller amount than requested (but by at least 1 more element)
 
-#define m_new(type, num) ((type*)(m_malloc(sizeof(type) * (num))))
-#define m_new_maybe(type, num) ((type*)(m_malloc_maybe(sizeof(type) * (num))))
-#define m_new0(type, num) ((type*)(m_malloc0(sizeof(type) * (num))))
+#define m_new(type, num) ((type *)(m_malloc(sizeof(type) * (num))))
+#define m_new_maybe(type, num) ((type *)(m_malloc_maybe(sizeof(type) * (num))))
+#define m_new0(type, num) ((type *)(m_malloc0(sizeof(type) * (num))))
 #define m_new_obj(type) (m_new(type, 1))
 #define m_new_obj_maybe(type) (m_new_maybe(type, 1))
-#define m_new_obj_var(obj_type, var_type, var_num) ((obj_type*)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))
-#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type*)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
+#define m_new_obj_var(obj_type, var_type, var_num) ((obj_type *)m_malloc(sizeof(obj_type) + sizeof(var_type) * (var_num)))
+#define m_new_obj_var_maybe(obj_type, var_type, var_num) ((obj_type *)m_malloc_maybe(sizeof(obj_type) + sizeof(var_type) * (var_num)))
 #if MICROPY_ENABLE_FINALISER
-#define m_new_obj_with_finaliser(type) ((type*)(m_malloc_with_finaliser(sizeof(type))))
-#define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type*)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num)))
+#define m_new_obj_with_finaliser(type) ((type *)(m_malloc_with_finaliser(sizeof(type))))
+#define m_new_obj_var_with_finaliser(type, var_type, var_num) ((type *)m_malloc_with_finaliser(sizeof(type) + sizeof(var_type) * (var_num)))
 #else
 #define m_new_obj_with_finaliser(type) m_new_obj(type)
 #define m_new_obj_var_with_finaliser(type, var_type, var_num) m_new_obj_var(type, var_type, var_num)
 #endif
 #if MICROPY_MALLOC_USES_ALLOCATED_SIZE
-#define m_renew(type, ptr, old_num, new_num) ((type*)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
-#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type*)(m_realloc_maybe((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num), (allow_move))))
+#define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num))))
+#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (old_num), sizeof(type) * (new_num), (allow_move))))
 #define m_del(type, ptr, num) m_free(ptr, sizeof(type) * (num))
 #define m_del_var(obj_type, var_type, var_num, ptr) (m_free(ptr, sizeof(obj_type) + sizeof(var_type) * (var_num)))
 #else
-#define m_renew(type, ptr, old_num, new_num) ((type*)(m_realloc((ptr), sizeof(type) * (new_num))))
-#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type*)(m_realloc_maybe((ptr), sizeof(type) * (new_num), (allow_move))))
+#define m_renew(type, ptr, old_num, new_num) ((type *)(m_realloc((ptr), sizeof(type) * (new_num))))
+#define m_renew_maybe(type, ptr, old_num, new_num, allow_move) ((type *)(m_realloc_maybe((ptr), sizeof(type) * (new_num), (allow_move))))
 #define m_del(type, ptr, num) ((void)(num), m_free(ptr))
 #define m_del_var(obj_type, var_type, var_num, ptr) ((void)(var_num), m_free(ptr))
 #endif
@@ -111,7 +111,7 @@
 #define MP_ARRAY_SIZE(a) (sizeof(a) / sizeof((a)[0]))
 
 // align ptr to the nearest multiple of "alignment"
-#define MP_ALIGN(ptr, alignment) (void*)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))
+#define MP_ALIGN(ptr, alignment) (void *)(((uintptr_t)(ptr) + ((alignment) - 1)) & ~((alignment) - 1))
 
 /** unichar / UTF-8 *********************************************/
 
@@ -129,9 +129,16 @@
 const byte *utf8_next_char(const byte *s);
 size_t utf8_charlen(const byte *str, size_t len);
 #else
-static inline unichar utf8_get_char(const byte *s) { return *s; }
-static inline const byte *utf8_next_char(const byte *s) { return s + 1; }
-static inline size_t utf8_charlen(const byte *str, size_t len) { (void)str; return len; }
+static inline unichar utf8_get_char(const byte *s) {
+    return *s;
+}
+static inline const byte *utf8_next_char(const byte *s) {
+    return s + 1;
+}
+static inline size_t utf8_charlen(const byte *str, size_t len) {
+    (void)str;
+    return len;
+}
 #endif
 
 bool unichar_isspace(unichar c);
@@ -169,9 +176,15 @@
 void vstr_clear(vstr_t *vstr);
 vstr_t *vstr_new(size_t alloc);
 void vstr_free(vstr_t *vstr);
-static inline void vstr_reset(vstr_t *vstr) { vstr->len = 0; }
-static inline char *vstr_str(vstr_t *vstr) { return vstr->buf; }
-static inline size_t vstr_len(vstr_t *vstr) { return vstr->len; }
+static inline void vstr_reset(vstr_t *vstr) {
+    vstr->len = 0;
+}
+static inline char *vstr_str(vstr_t *vstr) {
+    return vstr->buf;
+}
+static inline size_t vstr_len(vstr_t *vstr) {
+    return vstr->len;
+}
 void vstr_hint_size(vstr_t *vstr, size_t size);
 char *vstr_extend(vstr_t *vstr, size_t size);
 char *vstr_add_len(vstr_t *vstr, size_t len);
@@ -192,10 +205,10 @@
 #define CHECKBUF(buf, max_size) char buf[max_size + 1]; size_t buf##_len = max_size; char *buf##_p = buf;
 #define CHECKBUF_RESET(buf, max_size) buf##_len = max_size; buf##_p = buf;
 #define CHECKBUF_APPEND(buf, src, src_len) \
-        { size_t l = MIN(src_len, buf##_len); \
-        memcpy(buf##_p, src, l); \
-        buf##_len -= l; \
-        buf##_p += l; }
+    { size_t l = MIN(src_len, buf##_len); \
+      memcpy(buf##_p, src, l); \
+      buf##_len -= l; \
+      buf##_p += l; }
 #define CHECKBUF_APPEND_0(buf) { *buf##_p = 0; }
 #define CHECKBUF_LEN(buf) (buf##_p - buf)
 
diff --git a/py/modarray.c b/py/modarray.c
index b459a83..9ab1795 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -37,7 +37,7 @@
 
 const mp_obj_module_t mp_module_uarray = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_array_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_array_globals,
 };
 
 MP_REGISTER_MODULE(MP_QSTR_uarray, mp_module_uarray, MICROPY_PY_ARRAY);
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 6065bfd..299ec2d 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -140,7 +140,8 @@
     uint8_t str[4];
     int len = 0;
     if (c < 0x80) {
-        *str = c; len = 1;
+        *str = c;
+        len = 1;
     } else if (c < 0x800) {
         str[0] = (c >> 6) | 0xC0;
         str[1] = (c & 0x3F) | 0x80;
@@ -159,12 +160,12 @@
     } else {
         mp_raise_ValueError("chr() arg not in range(0x110000)");
     }
-    return mp_obj_new_str_via_qstr((char*)str, len);
+    return mp_obj_new_str_via_qstr((char *)str, len);
     #else
     mp_int_t ord = mp_obj_get_int(o_in);
     if (0 <= ord && ord <= 0xff) {
         uint8_t str[1] = {ord};
-        return mp_obj_new_str_via_qstr((char*)str, 1);
+        return mp_obj_new_str_via_qstr((char *)str, 1);
     } else {
         mp_raise_ValueError("chr() arg not in range(256)");
     }
@@ -355,7 +356,7 @@
 
 STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
     size_t len;
-    const byte *str = (const byte*)mp_obj_str_get_data(o_in, &len);
+    const byte *str = (const byte *)mp_obj_str_get_data(o_in, &len);
     #if MICROPY_PY_BUILTINS_STR_UNICODE
     if (mp_obj_is_str(o_in)) {
         len = utf8_charlen(str, len);
@@ -382,15 +383,16 @@
 
 STATIC mp_obj_t mp_builtin_pow(size_t n_args, const mp_obj_t *args) {
     switch (n_args) {
-        case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
+        case 2:
+            return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
         default:
-#if !MICROPY_PY_BUILTINS_POW3
+            #if !MICROPY_PY_BUILTINS_POW3
             mp_raise_msg(&mp_type_NotImplementedError, "3-arg pow() not supported");
-#elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ
+            #elif MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_MPZ
             return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]);
-#else
+            #else
             return mp_obj_int_pow3(args[0], args[1], args[2]);
-#endif
+            #endif
     }
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
@@ -485,7 +487,7 @@
         }
 
         mp_obj_t mult = mp_binary_op(MP_BINARY_OP_POWER, MP_OBJ_NEW_SMALL_INT(10), MP_OBJ_NEW_SMALL_INT(-num_dig));
-        mp_obj_t half_mult =  mp_binary_op(MP_BINARY_OP_FLOOR_DIVIDE, mult, MP_OBJ_NEW_SMALL_INT(2));
+        mp_obj_t half_mult = mp_binary_op(MP_BINARY_OP_FLOOR_DIVIDE, mult, MP_OBJ_NEW_SMALL_INT(2));
         mp_obj_t modulo = mp_binary_op(MP_BINARY_OP_MODULO, o_in, mult);
         mp_obj_t rounded = mp_binary_op(MP_BINARY_OP_SUBTRACT, o_in, modulo);
         if (mp_obj_is_true(mp_binary_op(MP_BINARY_OP_MORE, half_mult, modulo))) {
@@ -503,7 +505,7 @@
         }
         #endif
     }
-#if MICROPY_PY_BUILTINS_FLOAT
+    #if MICROPY_PY_BUILTINS_FLOAT
     mp_float_t val = mp_obj_get_float(o_in);
     if (n_args > 1) {
         mp_int_t num_dig = mp_obj_get_int(args[1]);
@@ -514,18 +516,22 @@
     }
     mp_float_t rounded = MICROPY_FLOAT_C_FUN(nearbyint)(val);
     return mp_obj_new_int_from_float(rounded);
-#else
+    #else
     mp_int_t r = mp_obj_get_int(o_in);
     return mp_obj_new_int(r);
-#endif
+    #endif
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_round_obj, 1, 2, mp_builtin_round);
 
 STATIC mp_obj_t mp_builtin_sum(size_t n_args, const mp_obj_t *args) {
     mp_obj_t value;
     switch (n_args) {
-        case 1: value = MP_OBJ_NEW_SMALL_INT(0); break;
-        default: value = args[1]; break;
+        case 1:
+            value = MP_OBJ_NEW_SMALL_INT(0);
+            break;
+        default:
+            value = args[1];
+            break;
     }
     mp_obj_iter_buf_t iter_buf;
     mp_obj_t iterable = mp_getiter(args[0], &iter_buf);
@@ -771,5 +777,5 @@
 
 const mp_obj_module_t mp_module_builtins = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_builtins_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_builtins_globals,
 };
diff --git a/py/modcmath.c b/py/modcmath.c
index 70fd542..ce1f474 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -43,7 +43,7 @@
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
     mp_obj_t tuple[2] = {
-        mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real*real + imag*imag)),
+        mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(real * real + imag * imag)),
         mp_obj_new_float(MICROPY_FLOAT_C_FUN(atan2)(imag, real)),
     };
     return mp_obj_new_tuple(2, tuple);
@@ -72,7 +72,7 @@
 STATIC mp_obj_t mp_cmath_log(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
-    return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log)(real*real + imag*imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real));
+    return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log)(real * real + imag * imag), MICROPY_FLOAT_C_FUN(atan2)(imag, real));
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log_obj, mp_cmath_log);
 
@@ -81,7 +81,7 @@
 STATIC mp_obj_t mp_cmath_log10(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
-    return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log10)(real*real + imag*imag), 0.4342944819032518 * MICROPY_FLOAT_C_FUN(atan2)(imag, real));
+    return mp_obj_new_complex(0.5 * MICROPY_FLOAT_C_FUN(log10)(real * real + imag * imag), 0.4342944819032518 * MICROPY_FLOAT_C_FUN(atan2)(imag, real));
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_cmath_log10_obj, mp_cmath_log10);
 #endif
@@ -90,7 +90,7 @@
 STATIC mp_obj_t mp_cmath_sqrt(mp_obj_t z_obj) {
     mp_float_t real, imag;
     mp_obj_get_complex(z_obj, &real, &imag);
-    mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real*real + imag*imag, 0.25);
+    mp_float_t sqrt_abs = MICROPY_FLOAT_C_FUN(pow)(real * real + imag * imag, 0.25);
     mp_float_t theta = 0.5 * MICROPY_FLOAT_C_FUN(atan2)(imag, real);
     return mp_obj_new_complex(sqrt_abs * MICROPY_FLOAT_C_FUN(cos)(theta), sqrt_abs * MICROPY_FLOAT_C_FUN(sin)(theta));
 }
@@ -146,7 +146,7 @@
 
 const mp_obj_module_t mp_module_cmath = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_cmath_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_cmath_globals,
 };
 
 #endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH
diff --git a/py/modcollections.c b/py/modcollections.c
index bb64884..c145f12 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -43,7 +43,7 @@
 
 const mp_obj_module_t mp_module_collections = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_collections_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_collections_globals,
 };
 
 #endif // MICROPY_PY_COLLECTIONS
diff --git a/py/modgc.c b/py/modgc.c
index 55e73de..534a711 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -33,11 +33,11 @@
 // collect(): run a garbage collection
 STATIC mp_obj_t py_gc_collect(void) {
     gc_collect();
-#if MICROPY_PY_GC_COLLECT_RETVAL
+    #if MICROPY_PY_GC_COLLECT_RETVAL
     return MP_OBJ_NEW_SMALL_INT(MP_STATE_MEM(gc_collected));
-#else
+    #else
     return mp_const_none;
-#endif
+    #endif
 }
 MP_DEFINE_CONST_FUN_OBJ_0(gc_collect_obj, py_gc_collect);
 
@@ -112,7 +112,7 @@
 
 const mp_obj_module_t mp_module_gc = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_gc_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_gc_globals,
 };
 
 #endif
diff --git a/py/modio.c b/py/modio.c
index 94ef5d4..14f5f21 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -72,7 +72,7 @@
 }
 
 STATIC mp_uint_t iobase_write(mp_obj_t obj, const void *buf, mp_uint_t size, int *errcode) {
-    return iobase_read_write(obj, (void*)buf, size, errcode, MP_QSTR_write);
+    return iobase_read_write(obj, (void *)buf, size, errcode, MP_QSTR_write);
 }
 
 STATIC mp_uint_t iobase_ioctl(mp_obj_t obj, mp_uint_t request, uintptr_t arg, int *errcode) {
@@ -144,7 +144,7 @@
         // is word-aligned, to guard against obscure cases when it matters, e.g.
         // https://github.com/micropython/micropython/issues/1863
         memcpy(self->buf + self->len, buf, rem);
-        buf = (byte*)buf + rem;
+        buf = (byte *)buf + rem;
         size -= rem;
         mp_uint_t out_sz = mp_stream_write_exactly(self->stream, self->buf, self->alloc, errcode);
         (void)out_sz;
@@ -195,7 +195,7 @@
     .name = MP_QSTR_BufferedWriter,
     .make_new = bufwriter_make_new,
     .protocol = &bufwriter_stream_p,
-    .locals_dict = (mp_obj_dict_t*)&bufwriter_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&bufwriter_locals_dict,
 };
 #endif // MICROPY_PY_IO_BUFFEREDWRITER
 
@@ -231,14 +231,14 @@
         mp_obj_stringio_t *o = m_new_obj(mp_obj_stringio_t);
         o->base.type = &mp_type_bytesio;
         o->vstr = m_new_obj(vstr_t);
-        vstr_init_fixed_buf(o->vstr, len + 1, (char*)data);
+        vstr_init_fixed_buf(o->vstr, len + 1, (char *)data);
         o->vstr->len = len;
         o->pos = 0;
         return MP_OBJ_FROM_PTR(o);
     }
 
     mp_obj_t path_out = mp_obj_new_str(path_buf.buf, path_buf.len);
-    return mp_builtin_open(1, &path_out, (mp_map_t*)&mp_const_empty_map);
+    return mp_builtin_open(1, &path_out, (mp_map_t *)&mp_const_empty_map);
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_2(resource_stream_obj, resource_stream);
 #endif
@@ -273,7 +273,7 @@
 
 const mp_obj_module_t mp_module_io = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_io_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_io_globals,
 };
 
 #endif
diff --git a/py/modmath.c b/py/modmath.c
index 35bb44b..5fe8e49 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -59,30 +59,30 @@
 }
 
 #define MATH_FUN_1(py_name, c_name) \
-    STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { \
         return math_generic_1(x_obj, MICROPY_FLOAT_C_FUN(c_name)); \
     } \
-    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_1_TO_BOOL(py_name, c_name) \
-    STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
-    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_bool(c_name(mp_obj_get_float(x_obj))); } \
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_1_TO_INT(py_name, c_name) \
-    STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
-    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj) { return mp_obj_new_int_from_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj))); } \
+    STATIC MP_DEFINE_CONST_FUN_OBJ_1(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_2(py_name, c_name) \
-    STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
         return math_generic_2(x_obj, y_obj, MICROPY_FLOAT_C_FUN(c_name)); \
     } \
-    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #define MATH_FUN_2_FLT_INT(py_name, c_name) \
-    STATIC mp_obj_t mp_math_ ## py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
+    STATIC mp_obj_t mp_math_##py_name(mp_obj_t x_obj, mp_obj_t y_obj) { \
         return mp_obj_new_float(MICROPY_FLOAT_C_FUN(c_name)(mp_obj_get_float(x_obj), mp_obj_get_int(y_obj))); \
     } \
-    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_## py_name ## _obj, mp_math_ ## py_name);
+    STATIC MP_DEFINE_CONST_FUN_OBJ_2(mp_math_##py_name##_obj, mp_math_##py_name);
 
 #if MP_NEED_LOG2
 #undef log2
@@ -392,7 +392,7 @@
 
 const mp_obj_module_t mp_module_math = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_math_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_math_globals,
 };
 
 #endif // MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH
diff --git a/py/modmicropython.c b/py/modmicropython.c
index 8d36697..d73d2bd 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -68,25 +68,25 @@
 
 mp_obj_t mp_micropython_mem_info(size_t n_args, const mp_obj_t *args) {
     (void)args;
-#if MICROPY_MEM_STATS
+    #if MICROPY_MEM_STATS
     mp_printf(&mp_plat_print, "mem: total=" UINT_FMT ", current=" UINT_FMT ", peak=" UINT_FMT "\n",
         (mp_uint_t)m_get_total_bytes_allocated(), (mp_uint_t)m_get_current_bytes_allocated(), (mp_uint_t)m_get_peak_bytes_allocated());
-#endif
-#if MICROPY_STACK_CHECK
+    #endif
+    #if MICROPY_STACK_CHECK
     mp_printf(&mp_plat_print, "stack: " UINT_FMT " out of " UINT_FMT "\n",
         mp_stack_usage(), (mp_uint_t)MP_STATE_THREAD(stack_limit));
-#else
+    #else
     mp_printf(&mp_plat_print, "stack: " UINT_FMT "\n", mp_stack_usage());
-#endif
-#if MICROPY_ENABLE_GC
+    #endif
+    #if MICROPY_ENABLE_GC
     gc_dump_info();
     if (n_args == 1) {
         // arg given means dump gc allocation table
         gc_dump_alloc_table();
     }
-#else
+    #else
     (void)n_args;
-#endif
+    #endif
     return mp_const_none;
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_micropython_mem_info_obj, 0, 1, mp_micropython_mem_info);
@@ -163,21 +163,21 @@
     #if MICROPY_ENABLE_COMPILER
     { MP_ROM_QSTR(MP_QSTR_opt_level), MP_ROM_PTR(&mp_micropython_opt_level_obj) },
     #endif
-#if MICROPY_PY_MICROPYTHON_MEM_INFO
-#if MICROPY_MEM_STATS
+    #if MICROPY_PY_MICROPYTHON_MEM_INFO
+    #if MICROPY_MEM_STATS
     { MP_ROM_QSTR(MP_QSTR_mem_total), MP_ROM_PTR(&mp_micropython_mem_total_obj) },
     { MP_ROM_QSTR(MP_QSTR_mem_current), MP_ROM_PTR(&mp_micropython_mem_current_obj) },
     { MP_ROM_QSTR(MP_QSTR_mem_peak), MP_ROM_PTR(&mp_micropython_mem_peak_obj) },
-#endif
+    #endif
     { MP_ROM_QSTR(MP_QSTR_mem_info), MP_ROM_PTR(&mp_micropython_mem_info_obj) },
     { MP_ROM_QSTR(MP_QSTR_qstr_info), MP_ROM_PTR(&mp_micropython_qstr_info_obj) },
-#endif
+    #endif
     #if MICROPY_PY_MICROPYTHON_STACK_USE
     { MP_ROM_QSTR(MP_QSTR_stack_use), MP_ROM_PTR(&mp_micropython_stack_use_obj) },
     #endif
-#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0)
+    #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF && (MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE == 0)
     { MP_ROM_QSTR(MP_QSTR_alloc_emergency_exception_buf), MP_ROM_PTR(&mp_alloc_emergency_exception_buf_obj) },
-#endif
+    #endif
     #if MICROPY_ENABLE_PYSTACK
     { MP_ROM_QSTR(MP_QSTR_pystack_use), MP_ROM_PTR(&mp_micropython_pystack_use_obj) },
     #endif
@@ -197,5 +197,5 @@
 
 const mp_obj_module_t mp_module_micropython = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_micropython_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_micropython_globals,
 };
diff --git a/py/modstruct.c b/py/modstruct.c
index 36af426..caf0ad9 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -217,7 +217,7 @@
     mp_int_t size = MP_OBJ_SMALL_INT_VALUE(struct_calcsize(args[0]));
     vstr_t vstr;
     vstr_init_len(&vstr, size);
-    byte *p = (byte*)vstr.buf;
+    byte *p = (byte *)vstr.buf;
     memset(p, 0, size);
     struct_pack_into_internal(args[0], p, n_args - 1, &args[1]);
     return mp_obj_new_str_from_vstr(&mp_type_bytes, &vstr);
@@ -263,7 +263,7 @@
 
 const mp_obj_module_t mp_module_ustruct = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_struct_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_struct_globals,
 };
 
 #endif
diff --git a/py/modsys.c b/py/modsys.c
index 29fac7c..8092d97 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -89,8 +89,8 @@
     mp_sys_implementation_obj,
     impl_fields,
     2 + MICROPY_PERSISTENT_CODE_LOAD,
-        SYS_IMPLEMENTATION_ELEMS
-);
+    SYS_IMPLEMENTATION_ELEMS
+    );
 #else
 STATIC const mp_rom_obj_tuple_t mp_sys_implementation_obj = {
     {&mp_type_tuple},
@@ -252,7 +252,7 @@
 
 const mp_obj_module_t mp_module_sys = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_sys_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_sys_globals,
 };
 
 #endif
diff --git a/py/modthread.c b/py/modthread.c
index f54bf83..35e7d50 100644
--- a/py/modthread.c
+++ b/py/modthread.c
@@ -120,7 +120,7 @@
 STATIC const mp_obj_type_t mp_type_thread_lock = {
     { &mp_type_type },
     .name = MP_QSTR_lock,
-    .locals_dict = (mp_obj_dict_t*)&thread_lock_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&thread_lock_locals_dict,
 };
 
 /****************************************************************/
@@ -157,7 +157,7 @@
 STATIC void *thread_entry(void *args_in) {
     // Execution begins here for a new thread.  We do not have the GIL.
 
-    thread_entry_args_t *args = (thread_entry_args_t*)args_in;
+    thread_entry_args_t *args = (thread_entry_args_t *)args_in;
 
     mp_state_thread_t ts;
     mp_thread_set_state(&ts);
@@ -193,7 +193,7 @@
     } else {
         // uncaught exception
         // check for SystemExit
-        mp_obj_base_t *exc = (mp_obj_base_t*)nlr.ret_val;
+        mp_obj_base_t *exc = (mp_obj_base_t *)nlr.ret_val;
         if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(exc->type), MP_OBJ_FROM_PTR(&mp_type_SystemExit))) {
             // swallow exception silently
         } else {
@@ -237,7 +237,7 @@
         if (mp_obj_get_type(args[2]) != &mp_type_dict) {
             mp_raise_TypeError("expecting a dict for keyword args");
         }
-        mp_map_t *map = &((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[2]))->map;
+        mp_map_t *map = &((mp_obj_dict_t *)MP_OBJ_TO_PTR(args[2]))->map;
         th_args = m_new_obj_var(thread_entry_args_t, mp_obj_t, pos_args_len + 2 * map->used);
         th_args->n_kw = map->used;
         // copy across the keyword arguments
@@ -294,7 +294,7 @@
 
 const mp_obj_module_t mp_module_thread = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_thread_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_thread_globals,
 };
 
 #endif // MICROPY_PY_THREAD
diff --git a/py/moduerrno.c b/py/moduerrno.c
index 0e0a3f0..93a08d8 100644
--- a/py/moduerrno.c
+++ b/py/moduerrno.c
@@ -63,9 +63,9 @@
 
 #if MICROPY_PY_UERRNO_ERRORCODE
 STATIC const mp_rom_map_elem_t errorcode_table[] = {
-    #define X(e) { MP_ROM_INT(MP_ ## e), MP_ROM_QSTR(MP_QSTR_## e) },
+    #define X(e) { MP_ROM_INT(MP_##e), MP_ROM_QSTR(MP_QSTR_##e) },
     MICROPY_PY_UERRNO_LIST
-    #undef X
+#undef X
 };
 
 STATIC const mp_obj_dict_t errorcode_dict = {
@@ -76,7 +76,7 @@
         .is_ordered = 1,
         .used = MP_ARRAY_SIZE(errorcode_table),
         .alloc = MP_ARRAY_SIZE(errorcode_table),
-        .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)errorcode_table,
+        .table = (mp_map_elem_t *)(mp_rom_map_elem_t *)errorcode_table,
     },
 };
 #endif
@@ -87,22 +87,22 @@
     { MP_ROM_QSTR(MP_QSTR_errorcode), MP_ROM_PTR(&errorcode_dict) },
     #endif
 
-    #define X(e) { MP_ROM_QSTR(MP_QSTR_## e), MP_ROM_INT(MP_ ## e) },
+    #define X(e) { MP_ROM_QSTR(MP_QSTR_##e), MP_ROM_INT(MP_##e) },
     MICROPY_PY_UERRNO_LIST
-    #undef X
+#undef X
 };
 
 STATIC MP_DEFINE_CONST_DICT(mp_module_uerrno_globals, mp_module_uerrno_globals_table);
 
 const mp_obj_module_t mp_module_uerrno = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&mp_module_uerrno_globals,
+    .globals = (mp_obj_dict_t *)&mp_module_uerrno_globals,
 };
 
 qstr mp_errno_to_str(mp_obj_t errno_val) {
     #if MICROPY_PY_UERRNO_ERRORCODE
     // We have the errorcode dict so can do a lookup using the hash map
-    mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP);
+    mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&errorcode_dict.map, errno_val, MP_MAP_LOOKUP);
     if (elem == NULL) {
         return MP_QSTRnull;
     } else {
diff --git a/py/mpconfig.h b/py/mpconfig.h
index f2754dd..4cefdf3 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.h
@@ -34,8 +34,8 @@
 // Combined version as a 32-bit number for convenience
 #define MICROPY_VERSION ( \
     MICROPY_VERSION_MAJOR << 16 \
-    | MICROPY_VERSION_MINOR << 8 \
-    | MICROPY_VERSION_MICRO)
+        | MICROPY_VERSION_MINOR << 8 \
+        | MICROPY_VERSION_MICRO)
 
 // String version
 #define MICROPY_VERSION_STRING \
@@ -550,9 +550,9 @@
 #define MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF (0)
 #endif
 #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
-#   ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
-#   define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)   // 0 - implies dynamic allocation
-#   endif
+#ifndef MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
+#define MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE (0)      // 0 - implies dynamic allocation
+#endif
 #endif
 
 // Whether to provide the mp_kbd_exception object, and micropython.kbd_intr function
@@ -1489,7 +1489,7 @@
 #elif defined(MP_ENDIANNESS_BIG)
 #define MP_ENDIANNESS_LITTLE (!MP_ENDIANNESS_BIG)
 #else
-  // Endianness not defined by port so try to autodetect it.
+// Endianness not defined by port so try to autodetect it.
   #if defined(__BYTE_ORDER__)
     #if __BYTE_ORDER__ == __ORDER_LITTLE_ENDIAN__
       #define MP_ENDIANNESS_LITTLE (1)
@@ -1595,33 +1595,33 @@
 
 #ifndef MP_HTOBE16
 #if MP_ENDIANNESS_LITTLE
-# define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))
-# define MP_BE16TOH(x) MP_HTOBE16(x)
+#define MP_HTOBE16(x) ((uint16_t)( (((x) & 0xff) << 8) | (((x) >> 8) & 0xff) ))
+#define MP_BE16TOH(x) MP_HTOBE16(x)
 #else
-# define MP_HTOBE16(x) (x)
-# define MP_BE16TOH(x) (x)
+#define MP_HTOBE16(x) (x)
+#define MP_BE16TOH(x) (x)
 #endif
 #endif
 
 #ifndef MP_HTOBE32
 #if MP_ENDIANNESS_LITTLE
-# define MP_HTOBE32(x) ((uint32_t)( (((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8)  & 0xff00) | (((x) >> 24) & 0xff) ))
-# define MP_BE32TOH(x) MP_HTOBE32(x)
+#define MP_HTOBE32(x) ((uint32_t)( (((x) & 0xff) << 24) | (((x) & 0xff00) << 8) | (((x) >> 8) & 0xff00) | (((x) >> 24) & 0xff) ))
+#define MP_BE32TOH(x) MP_HTOBE32(x)
 #else
-# define MP_HTOBE32(x) (x)
-# define MP_BE32TOH(x) (x)
+#define MP_HTOBE32(x) (x)
+#define MP_BE32TOH(x) (x)
 #endif
 #endif
 
 // Warning categories are by default implemented as strings, though
 // hook is left for a port to define them as something else.
 #if MICROPY_WARNINGS_CATEGORY
-# ifndef MP_WARN_CAT
-# define MP_WARN_CAT(x) #x
-# endif
+#ifndef MP_WARN_CAT
+#define MP_WARN_CAT(x) #x
+#endif
 #else
-# undef MP_WARN_CAT
-# define MP_WARN_CAT(x) (NULL)
+#undef MP_WARN_CAT
+#define MP_WARN_CAT(x) (NULL)
 #endif
 
 // Feature dependency check.
diff --git a/py/mpprint.c b/py/mpprint.c
index cf09f7b..49653a0 100644
--- a/py/mpprint.c
+++ b/py/mpprint.c
@@ -269,14 +269,14 @@
         // We add the pad in this function, so since the pad goes after
         // the sign & prefix, we format without a prefix
         str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size,
-                                   x, base, NULL, base_char, comma);
+            x, base, NULL, base_char, comma);
         if (*str == '-') {
             sign = *str++;
             fmt_size--;
         }
     } else {
         str = mp_obj_int_formatted(&buf, &buf_size, &fmt_size,
-                                   x, base, prefix, base_char, comma);
+            x, base, prefix, base_char, comma);
     }
 
     int spaces_before = 0;
@@ -347,8 +347,7 @@
 
     if (flags & PF_FLAG_SHOW_SIGN) {
         sign = '+';
-    }
-    else
+    } else
     if (flags & PF_FLAG_SPACE_SIGN) {
         sign = ' ';
     }
@@ -411,14 +410,20 @@
         int flags = 0;
         char fill = ' ';
         while (*fmt != '\0') {
-            if (*fmt == '-') flags |= PF_FLAG_LEFT_ADJUST;
-            else if (*fmt == '+') flags |= PF_FLAG_SHOW_SIGN;
-            else if (*fmt == ' ') flags |= PF_FLAG_SPACE_SIGN;
-            else if (*fmt == '!') flags |= PF_FLAG_NO_TRAILZ;
-            else if (*fmt == '0') {
+            if (*fmt == '-') {
+                flags |= PF_FLAG_LEFT_ADJUST;
+            } else if (*fmt == '+') {
+                flags |= PF_FLAG_SHOW_SIGN;
+            } else if (*fmt == ' ') {
+                flags |= PF_FLAG_SPACE_SIGN;
+            } else if (*fmt == '!') {
+                flags |= PF_FLAG_NO_TRAILZ;
+            } else if (*fmt == '0') {
                 flags |= PF_FLAG_PAD_AFTER_SIGN;
                 fill = '0';
-            } else break;
+            } else {
+                break;
+            }
             ++fmt;
         }
 
@@ -470,26 +475,23 @@
                     chrs += mp_print_strn(print, "false", 5, flags, fill, width);
                 }
                 break;
-            case 'c':
-            {
+            case 'c': {
                 char str = va_arg(args, int);
                 chrs += mp_print_strn(print, &str, 1, flags, fill, width);
                 break;
             }
-            case 'q':
-            {
+            case 'q': {
                 qstr qst = va_arg(args, qstr);
                 size_t len;
-                const char *str = (const char*)qstr_data(qst, &len);
+                const char *str = (const char *)qstr_data(qst, &len);
                 if (prec < 0) {
                     prec = len;
                 }
                 chrs += mp_print_strn(print, str, prec, flags, fill, width);
                 break;
             }
-            case 's':
-            {
-                const char *str = va_arg(args, const char*);
+            case 's': {
+                const char *str = va_arg(args, const char *);
                 #ifndef NDEBUG
                 // With debugging enabled, catch printing of null string pointers
                 if (prec != 0 && str == NULL) {
@@ -532,26 +534,25 @@
                 // Use unsigned long int to work on both ILP32 and LP64 systems
                 chrs += mp_print_int(print, va_arg(args, unsigned long int), 0, 16, 'a', flags, fill, width);
                 break;
-#if MICROPY_PY_BUILTINS_FLOAT
+            #if MICROPY_PY_BUILTINS_FLOAT
             case 'e':
             case 'E':
             case 'f':
             case 'F':
             case 'g':
-            case 'G':
-            {
-#if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
+            case 'G': {
+                #if ((MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT) || (MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE))
                 mp_float_t f = va_arg(args, double);
                 chrs += mp_print_float(print, f, *fmt, flags, fill, width, prec);
-#else
-#error Unknown MICROPY FLOAT IMPL
-#endif
+                #else
+                #error Unknown MICROPY FLOAT IMPL
+                #endif
                 break;
             }
-#endif
-            // Because 'l' is eaten above, another 'l' means %ll.  We need to support
-            // this length specifier for OBJ_REPR_D (64-bit NaN boxing).
-            // TODO Either enable this unconditionally, or provide a specific config var.
+            #endif
+                // Because 'l' is eaten above, another 'l' means %ll.  We need to support
+                // this length specifier for OBJ_REPR_D (64-bit NaN boxing).
+                // TODO Either enable this unconditionally, or provide a specific config var.
             #if (MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D) || defined(_WIN64)
             case 'l': {
                 unsigned long long int arg_value = va_arg(args, unsigned long long int);
diff --git a/py/mpprint.h b/py/mpprint.h
index 07462bd..aef9015 100644
--- a/py/mpprint.h
+++ b/py/mpprint.h
@@ -40,9 +40,9 @@
 #define PF_FLAG_SHOW_OCTAL_LETTER (0x200)
 
 #if MICROPY_PY_IO && MICROPY_PY_SYS_STDFILES
-#    define MP_PYTHON_PRINTER &mp_sys_stdout_print
+#define MP_PYTHON_PRINTER &mp_sys_stdout_print
 #else
-#    define MP_PYTHON_PRINTER &mp_plat_print
+#define MP_PYTHON_PRINTER &mp_plat_print
 #endif
 
 typedef void (*mp_print_strn_t)(void *data, const char *str, size_t len);
diff --git a/py/mpthread.h b/py/mpthread.h
index f2ab081..e611ef4 100644
--- a/py/mpthread.h
+++ b/py/mpthread.h
@@ -40,7 +40,7 @@
 
 struct _mp_state_thread_t *mp_thread_get_state(void);
 void mp_thread_set_state(struct _mp_state_thread_t *state);
-void mp_thread_create(void *(*entry)(void*), void *arg, size_t *stack_size);
+void mp_thread_create(void *(*entry)(void *), void *arg, size_t *stack_size);
 void mp_thread_start(void);
 void mp_thread_finish(void);
 void mp_thread_mutex_init(mp_thread_mutex_t *mutex);
diff --git a/py/mpz.c b/py/mpz.c
index d79d16d..fb9ac6e 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -60,13 +60,21 @@
    assumes i, j are normalised
 */
 STATIC int mpn_cmp(const mpz_dig_t *idig, size_t ilen, const mpz_dig_t *jdig, size_t jlen) {
-    if (ilen < jlen) { return -1; }
-    if (ilen > jlen) { return 1; }
+    if (ilen < jlen) {
+        return -1;
+    }
+    if (ilen > jlen) {
+        return 1;
+    }
 
     for (idig += ilen, jdig += ilen; ilen > 0; --ilen) {
         mpz_dbl_dig_signed_t cmp = (mpz_dbl_dig_t)*(--idig) - (mpz_dbl_dig_t)*(--jdig);
-        if (cmp < 0) { return -1; }
-        if (cmp > 0) { return 1; }
+        if (cmp < 0) {
+            return -1;
+        }
+        if (cmp > 0) {
+            return 1;
+        }
     }
 
     return 0;
@@ -228,7 +236,7 @@
    can have i, j, k pointing to same memory
 */
 STATIC size_t mpn_and_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
-                            mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
+    mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
     mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK;
@@ -289,7 +297,7 @@
 #if MICROPY_OPT_MPZ_BITWISE
 
 STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
-                            mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
+    mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dbl_dig_t carryi = 1;
     mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK;
@@ -319,7 +327,7 @@
 #else
 
 STATIC size_t mpn_or_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
-                            mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
+    mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
     mpz_dig_t imask = (0 == carryi) ? 0 : DIG_MASK;
     mpz_dig_t jmask = (0 == carryj) ? 0 : DIG_MASK;
@@ -378,7 +386,7 @@
    can have i, j, k pointing to same memory
 */
 STATIC size_t mpn_xor_neg(mpz_dig_t *idig, const mpz_dig_t *jdig, size_t jlen, const mpz_dig_t *kdig, size_t klen,
-                              mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
+    mpz_dbl_dig_t carryi, mpz_dbl_dig_t carryj, mpz_dbl_dig_t carryk) {
     mpz_dig_t *oidig = idig;
 
     for (; jlen > 0; ++idig, ++jdig) {
@@ -812,16 +820,16 @@
                 z->dig[dig_ind++] = (frc << shft) & DIG_MASK;
                 frc >>= DIG_SIZE - shft;
             }
-#if DIG_SIZE < (MP_FLOAT_FRAC_BITS + 1)
+            #if DIG_SIZE < (MP_FLOAT_FRAC_BITS + 1)
             while (dig_ind != dig_cnt) {
                 z->dig[dig_ind++] = frc & DIG_MASK;
                 frc >>= DIG_SIZE;
             }
-#else
+            #else
             if (dig_ind != dig_cnt) {
                 z->dig[dig_ind] = frc;
             }
-#endif
+            #endif
         }
     }
 }
@@ -935,28 +943,48 @@
 mp_int_t mpz_cmp_sml_int(const mpz_t *z, mp_int_t sml_int) {
     mp_int_t cmp;
     if (z->neg == 0) {
-        if (sml_int < 0) return 1;
-        if (sml_int == 0) {
-            if (z->len == 0) return 0;
+        if (sml_int < 0) {
             return 1;
         }
-        if (z->len == 0) return -1;
-        assert(sml_int < (1 << DIG_SIZE));
-        if (z->len != 1) return 1;
-        cmp = z->dig[0] - sml_int;
-    } else {
-        if (sml_int > 0) return -1;
         if (sml_int == 0) {
-            if (z->len == 0) return 0;
+            if (z->len == 0) {
+                return 0;
+            }
+            return 1;
+        }
+        if (z->len == 0) {
             return -1;
         }
-        if (z->len == 0) return 1;
+        assert(sml_int < (1 << DIG_SIZE));
+        if (z->len != 1) {
+            return 1;
+        }
+        cmp = z->dig[0] - sml_int;
+    } else {
+        if (sml_int > 0) {
+            return -1;
+        }
+        if (sml_int == 0) {
+            if (z->len == 0) {
+                return 0;
+            }
+            return -1;
+        }
+        if (z->len == 0) {
+            return 1;
+        }
         assert(sml_int > -(1 << DIG_SIZE));
-        if (z->len != 1) return -1;
+        if (z->len != 1) {
+            return -1;
+        }
         cmp = -z->dig[0] - sml_int;
     }
-    if (cmp < 0) return -1;
-    if (cmp > 0) return 1;
+    if (cmp < 0) {
+        return -1;
+    }
+    if (cmp > 0) {
+        return 1;
+    }
     return 0;
 }
 #endif
@@ -1194,7 +1222,7 @@
     } else {
         mpz_need_dig(dest, lhs->len + 1);
         dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len,
-                                 lhs->neg == rhs->neg, 0 != lhs->neg, 0 != rhs->neg);
+            lhs->neg == rhs->neg, 0 != lhs->neg, 0 != rhs->neg);
         dest->neg = lhs->neg & rhs->neg;
     }
 
@@ -1202,7 +1230,7 @@
 
     mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg));
     dest->len = mpn_and_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len,
-                             (lhs->neg == rhs->neg) ? lhs->neg : 0, lhs->neg, rhs->neg);
+        (lhs->neg == rhs->neg) ? lhs->neg : 0, lhs->neg, rhs->neg);
     dest->neg = lhs->neg & rhs->neg;
 
     #endif
@@ -1228,7 +1256,7 @@
     } else {
         mpz_need_dig(dest, lhs->len + 1);
         dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len,
-                                 0 != lhs->neg, 0 != rhs->neg);
+            0 != lhs->neg, 0 != rhs->neg);
         dest->neg = 1;
     }
 
@@ -1236,7 +1264,7 @@
 
     mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg));
     dest->len = mpn_or_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len,
-                             (lhs->neg || rhs->neg), lhs->neg, rhs->neg);
+        (lhs->neg || rhs->neg), lhs->neg, rhs->neg);
     dest->neg = lhs->neg | rhs->neg;
 
     #endif
@@ -1266,7 +1294,7 @@
     } else {
         mpz_need_dig(dest, lhs->len + 1);
         dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len, 1,
-                                0 == lhs->neg, 0 == rhs->neg);
+            0 == lhs->neg, 0 == rhs->neg);
         dest->neg = 1;
     }
 
@@ -1274,7 +1302,7 @@
 
     mpz_need_dig(dest, lhs->len + (lhs->neg || rhs->neg));
     dest->len = mpn_xor_neg(dest->dig, lhs->dig, lhs->len, rhs->dig, rhs->len,
-                             (lhs->neg != rhs->neg), 0 == lhs->neg, 0 == rhs->neg);
+        (lhs->neg != rhs->neg), 0 == lhs->neg, 0 == rhs->neg);
     dest->neg = lhs->neg ^ rhs->neg;
 
     #endif
@@ -1363,7 +1391,8 @@
 
     mpz_t *x = mpz_clone(lhs);
     mpz_t *n = mpz_clone(rhs);
-    mpz_t quo; mpz_init_zero(&quo);
+    mpz_t quo;
+    mpz_init_zero(&quo);
 
     while (n->len > 0) {
         if ((n->dig[0] & 1) != 0) {
@@ -1406,7 +1435,8 @@
 
     mpz_t *a = mpz_clone(z1);
     mpz_t *b = mpz_clone(z2);
-    mpz_t c; mpz_init_zero(&c);
+    mpz_t c;
+    mpz_init_zero(&c);
     a->neg = 0;
     b->neg = 0;
 
@@ -1417,7 +1447,9 @@
                 mpz_deinit(&c);
                 return b;
             }
-            mpz_t *t = a; a = b; b = t;
+            mpz_t *t = a;
+            a = b;
+            b = t;
         }
         if (!(b->len >= 2 || (b->len == 1 && b->dig[0] > 1))) { // compute b > 0; could be mpz_cmp_small_int(b, 1) > 0
             break;
@@ -1484,7 +1516,8 @@
     if (lhs->neg != rhs->neg) {
         dest_quo->neg = 1;
         if (!mpz_is_zero(dest_rem)) {
-            mpz_t mpzone; mpz_init_from_int(&mpzone, -1);
+            mpz_t mpzone;
+            mpz_init_from_int(&mpzone, -1);
             mpz_add_inpl(dest_quo, dest_quo, &mpzone);
             mpz_add_inpl(dest_rem, dest_rem, rhs);
         }
@@ -1499,7 +1532,8 @@
 */
 mpz_t *mpz_div(const mpz_t *lhs, const mpz_t *rhs) {
     mpz_t *quo = mpz_zero();
-    mpz_t rem; mpz_init_zero(&rem);
+    mpz_t rem;
+    mpz_init_zero(&rem);
     mpz_divmod_inpl(quo, &rem, lhs, rhs);
     mpz_deinit(&rem);
     return quo;
@@ -1509,7 +1543,8 @@
    can have lhs, rhs the same
 */
 mpz_t *mpz_mod(const mpz_t *lhs, const mpz_t *rhs) {
-    mpz_t quo; mpz_init_zero(&quo);
+    mpz_t quo;
+    mpz_init_zero(&quo);
     mpz_t *rem = mpz_zero();
     mpz_divmod_inpl(&quo, rem, lhs, rhs);
     mpz_deinit(&quo);
@@ -1646,8 +1681,9 @@
     char *s = str;
     if (ilen == 0) {
         if (prefix) {
-            while (*prefix)
+            while (*prefix) {
                 *s++ = *prefix++;
+            }
         }
         *s++ = '0';
         *s = '\0';
diff --git a/py/mpz.h b/py/mpz.h
index 3c36cac..cc15049 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -46,10 +46,10 @@
 
 #ifndef MPZ_DIG_SIZE
   #if defined(__x86_64__) || defined(_WIN64)
-    // 64-bit machine, using 32-bit storage for digits
+// 64-bit machine, using 32-bit storage for digits
     #define MPZ_DIG_SIZE (32)
   #else
-    // default: 32-bit machine, using 16-bit storage for digits
+// default: 32-bit machine, using 16-bit storage for digits
     #define MPZ_DIG_SIZE (16)
   #endif
 #endif
@@ -99,7 +99,7 @@
 } mpz_t;
 
 // convenience macro to declare an mpz with a digit array from the stack, initialised by an integer
-#define MPZ_CONST_INT(z, val) mpz_t z; mpz_dig_t z ## _digits[MPZ_NUM_DIG_FOR_INT]; mpz_init_fixed_from_int(&z, z_digits, MPZ_NUM_DIG_FOR_INT, val);
+#define MPZ_CONST_INT(z, val) mpz_t z; mpz_dig_t z##_digits[MPZ_NUM_DIG_FOR_INT]; mpz_init_fixed_from_int(&z, z_digits, MPZ_NUM_DIG_FOR_INT, val);
 
 void mpz_init_zero(mpz_t *z);
 void mpz_init_from_int(mpz_t *z, mp_int_t val);
@@ -115,8 +115,12 @@
 size_t mpz_set_from_str(mpz_t *z, const char *str, size_t len, bool neg, unsigned int base);
 void mpz_set_from_bytes(mpz_t *z, bool big_endian, size_t len, const byte *buf);
 
-static inline bool mpz_is_zero(const mpz_t *z) { return z->len == 0; }
-static inline bool mpz_is_neg(const mpz_t *z) { return z->len != 0 && z->neg != 0; }
+static inline bool mpz_is_zero(const mpz_t *z) {
+    return z->len == 0;
+}
+static inline bool mpz_is_neg(const mpz_t *z) {
+    return z->len != 0 && z->neg != 0;
+}
 int mpz_cmp(const mpz_t *lhs, const mpz_t *rhs);
 
 void mpz_abs_inpl(mpz_t *dest, const mpz_t *z);
@@ -134,7 +138,9 @@
 void mpz_xor_inpl(mpz_t *dest, const mpz_t *lhs, const mpz_t *rhs);
 void mpz_divmod_inpl(mpz_t *dest_quo, mpz_t *dest_rem, const mpz_t *lhs, const mpz_t *rhs);
 
-static inline size_t mpz_max_num_bits(const mpz_t *z) { return z->len * MPZ_DIG_SIZE; }
+static inline size_t mpz_max_num_bits(const mpz_t *z) {
+    return z->len * MPZ_DIG_SIZE;
+}
 mp_int_t mpz_hash(const mpz_t *z);
 bool mpz_as_int_checked(const mpz_t *z, mp_int_t *value);
 bool mpz_as_uint_checked(const mpz_t *z, mp_uint_t *value);
diff --git a/py/nativeglue.c b/py/nativeglue.c
index 2e0ac56..ee38e4d 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -44,15 +44,24 @@
 
 int mp_native_type_from_qstr(qstr qst) {
     switch (qst) {
-        case MP_QSTR_object: return MP_NATIVE_TYPE_OBJ;
-        case MP_QSTR_bool: return MP_NATIVE_TYPE_BOOL;
-        case MP_QSTR_int: return MP_NATIVE_TYPE_INT;
-        case MP_QSTR_uint: return MP_NATIVE_TYPE_UINT;
-        case MP_QSTR_ptr: return MP_NATIVE_TYPE_PTR;
-        case MP_QSTR_ptr8: return MP_NATIVE_TYPE_PTR8;
-        case MP_QSTR_ptr16: return MP_NATIVE_TYPE_PTR16;
-        case MP_QSTR_ptr32: return MP_NATIVE_TYPE_PTR32;
-        default: return -1;
+        case MP_QSTR_object:
+            return MP_NATIVE_TYPE_OBJ;
+        case MP_QSTR_bool:
+            return MP_NATIVE_TYPE_BOOL;
+        case MP_QSTR_int:
+            return MP_NATIVE_TYPE_INT;
+        case MP_QSTR_uint:
+            return MP_NATIVE_TYPE_UINT;
+        case MP_QSTR_ptr:
+            return MP_NATIVE_TYPE_PTR;
+        case MP_QSTR_ptr8:
+            return MP_NATIVE_TYPE_PTR8;
+        case MP_QSTR_ptr16:
+            return MP_NATIVE_TYPE_PTR16;
+        case MP_QSTR_ptr32:
+            return MP_NATIVE_TYPE_PTR32;
+        default:
+            return -1;
     }
 }
 
@@ -60,10 +69,13 @@
 mp_uint_t mp_native_from_obj(mp_obj_t obj, mp_uint_t type) {
     DEBUG_printf("mp_native_from_obj(%p, " UINT_FMT ")\n", obj, type);
     switch (type & 0xf) {
-        case MP_NATIVE_TYPE_OBJ: return (mp_uint_t)obj;
-        case MP_NATIVE_TYPE_BOOL: return mp_obj_is_true(obj);
+        case MP_NATIVE_TYPE_OBJ:
+            return (mp_uint_t)obj;
+        case MP_NATIVE_TYPE_BOOL:
+            return mp_obj_is_true(obj);
         case MP_NATIVE_TYPE_INT:
-        case MP_NATIVE_TYPE_UINT: return mp_obj_get_int_truncated(obj);
+        case MP_NATIVE_TYPE_UINT:
+            return mp_obj_get_int_truncated(obj);
         default: { // cast obj to a pointer
             mp_buffer_info_t bufinfo;
             if (mp_get_buffer(obj, &bufinfo, MP_BUFFER_READ)) {
@@ -84,10 +96,14 @@
 mp_obj_t mp_native_to_obj(mp_uint_t val, mp_uint_t type) {
     DEBUG_printf("mp_native_to_obj(" UINT_FMT ", " UINT_FMT ")\n", val, type);
     switch (type & 0xf) {
-        case MP_NATIVE_TYPE_OBJ: return (mp_obj_t)val;
-        case MP_NATIVE_TYPE_BOOL: return mp_obj_new_bool(val);
-        case MP_NATIVE_TYPE_INT: return mp_obj_new_int(val);
-        case MP_NATIVE_TYPE_UINT: return mp_obj_new_int_from_uint(val);
+        case MP_NATIVE_TYPE_OBJ:
+            return (mp_obj_t)val;
+        case MP_NATIVE_TYPE_BOOL:
+            return mp_obj_new_bool(val);
+        case MP_NATIVE_TYPE_INT:
+            return mp_obj_new_int(val);
+        case MP_NATIVE_TYPE_UINT:
+            return mp_obj_new_int_from_uint(val);
         default: // a pointer
             // we return just the value of the pointer as an integer
             return mp_obj_new_int_from_uint(val);
diff --git a/py/nativeglue.h b/py/nativeglue.h
index 1b6d9cc..9e320ef 100644
--- a/py/nativeglue.h
+++ b/py/nativeglue.h
@@ -91,7 +91,7 @@
     mp_const_obj_t const_true;
     mp_uint_t (*native_from_obj)(mp_obj_t obj, mp_uint_t type);
     mp_obj_t (*native_to_obj)(mp_uint_t val, mp_uint_t type);
-    mp_obj_dict_t *(*swap_globals)(mp_obj_dict_t *new_globals);
+    mp_obj_dict_t *(*swap_globals)(mp_obj_dict_t * new_globals);
     mp_obj_t (*load_name)(qstr qst);
     mp_obj_t (*load_global)(qstr qst);
     mp_obj_t (*load_build_class)(void);
@@ -147,8 +147,8 @@
     #endif
     void (*raise_msg)(const mp_obj_type_t *exc_type, const char *msg);
     const mp_obj_type_t *(*obj_get_type)(mp_const_obj_t o_in);
-    mp_obj_t (*obj_new_str)(const char* data, size_t len);
-    mp_obj_t (*obj_new_bytes)(const byte* data, size_t len);
+    mp_obj_t (*obj_new_str)(const char *data, size_t len);
+    mp_obj_t (*obj_new_bytes)(const byte *data, size_t len);
     mp_obj_t (*obj_new_bytearray_by_ref)(size_t n, void *items);
     mp_obj_t (*obj_new_float_from_f)(float f);
     mp_obj_t (*obj_new_float_from_d)(double d);
diff --git a/py/nlr.c b/py/nlr.c
index 03d0157..a35e7d2 100644
--- a/py/nlr.c
+++ b/py/nlr.c
@@ -30,7 +30,7 @@
 // When not using setjmp, nlr_push_tail is called from inline asm so needs special care
 #if MICROPY_NLR_X86 && MICROPY_NLR_OS_WINDOWS
 // On these 32-bit platforms make sure nlr_push_tail doesn't have a leading underscore
-unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail");
+unsigned int nlr_push_tail(nlr_buf_t *nlr) asm ("nlr_push_tail");
 #else
 // LTO can't see inside inline asm functions so explicitly mark nlr_push_tail as used
 __attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr);
diff --git a/py/nlrpowerpc.c b/py/nlrpowerpc.c
index b403823..940d856 100644
--- a/py/nlrpowerpc.c
+++ b/py/nlrpowerpc.c
@@ -34,44 +34,44 @@
 
 unsigned int nlr_push(nlr_buf_t *nlr) {
 
-    __asm__ volatile(
-    "li     4, 0x4eed ; "      // Store canary
-    "std    4,  0x00(%0) ;"
-    "std    0,  0x08(%0) ;"
-    "std    1,  0x10(%0) ;"
-    "std    2,  0x18(%0) ;"
-    "std    14, 0x20(%0) ;"
-    "std    15, 0x28(%0) ;"
-    "std    16, 0x30(%0) ;"
-    "std    17, 0x38(%0) ;"
-    "std    18, 0x40(%0) ;"
-    "std    19, 0x48(%0) ;"
-    "std    20, 0x50(%0) ;"
-    "std    21, 0x58(%0) ;"
-    "std    22, 0x60(%0) ;"
-    "std    23, 0x68(%0) ;"
-    "std    24, 0x70(%0) ;"
-    "std    25, 0x78(%0) ;"
-    "std    26, 0x80(%0) ;"
-    "std    27, 0x88(%0) ;"
-    "std    28, 0x90(%0) ;"
-    "std    29, 0x98(%0) ;"
-    "std    30, 0xA0(%0) ;"
-    "std    31, 0xA8(%0) ;"
+    __asm__ volatile (
+        "li     4, 0x4eed ; "  // Store canary
+        "std    4,  0x00(%0) ;"
+        "std    0,  0x08(%0) ;"
+        "std    1,  0x10(%0) ;"
+        "std    2,  0x18(%0) ;"
+        "std    14, 0x20(%0) ;"
+        "std    15, 0x28(%0) ;"
+        "std    16, 0x30(%0) ;"
+        "std    17, 0x38(%0) ;"
+        "std    18, 0x40(%0) ;"
+        "std    19, 0x48(%0) ;"
+        "std    20, 0x50(%0) ;"
+        "std    21, 0x58(%0) ;"
+        "std    22, 0x60(%0) ;"
+        "std    23, 0x68(%0) ;"
+        "std    24, 0x70(%0) ;"
+        "std    25, 0x78(%0) ;"
+        "std    26, 0x80(%0) ;"
+        "std    27, 0x88(%0) ;"
+        "std    28, 0x90(%0) ;"
+        "std    29, 0x98(%0) ;"
+        "std    30, 0xA0(%0) ;"
+        "std    31, 0xA8(%0) ;"
 
-    "mfcr   4 ; "
-    "std    4, 0xB0(%0) ;"
-    "mflr   4 ;"
-    "std    4, 0xB8(%0) ;"
-    "li     4, nlr_push_tail@l ;"
-    "oris   4, 4, nlr_push_tail@h ;"
-    "mtctr  4 ;"
-    "mr    3, %1 ; "
-    "bctr  ;"
-    :
-    : "r"(&nlr->regs), "r"(nlr)
-    :
-    );
+        "mfcr   4 ; "
+        "std    4, 0xB0(%0) ;"
+        "mflr   4 ;"
+        "std    4, 0xB8(%0) ;"
+        "li     4, nlr_push_tail@l ;"
+        "oris   4, 4, nlr_push_tail@h ;"
+        "mtctr  4 ;"
+        "mr    3, %1 ; "
+        "bctr  ;"
+        :
+        : "r" (&nlr->regs), "r" (nlr)
+        :
+        );
 
     return 0;
 }
@@ -79,41 +79,41 @@
 NORETURN void nlr_jump(void *val) {
     MP_NLR_JUMP_HEAD(val, top)
 
-    __asm__ volatile(
-    "ld    3, 0x0(%0) ;"
-    "cmpdi 3, 0x4eed ; " // Check canary
-    "bne   . ; "
-    "ld    0,  0x08(%0) ;"
-    "ld    1,  0x10(%0) ;"
-    "ld    2,  0x18(%0) ;"
-    "ld    14, 0x20(%0) ;"
-    "ld    15, 0x28(%0) ;"
-    "ld    16, 0x30(%0) ;"
-    "ld    17, 0x38(%0) ;"
-    "ld    18, 0x40(%0) ;"
-    "ld    19, 0x48(%0) ;"
-    "ld    20, 0x50(%0) ;"
-    "ld    21, 0x58(%0) ;"
-    "ld    22, 0x60(%0) ;"
-    "ld    23, 0x68(%0) ;"
-    "ld    24, 0x70(%0) ;"
-    "ld    25, 0x78(%0) ;"
-    "ld    26, 0x80(%0) ;"
-    "ld    27, 0x88(%0) ;"
-    "ld    28, 0x90(%0) ;"
-    "ld    29, 0x98(%0) ;"
-    "ld    30, 0xA0(%0) ;"
-    "ld    31, 0xA8(%0) ;"
-    "ld    3,  0xB0(%0) ;"
-    "mtcr  3 ;"
-    "ld    3, 0xB8(%0) ;"
-    "mtlr  3 ; "
-    "li    3, 1;"
-    "blr ;"
-    :
-    : "r"(&top->regs)
-    :
-    );
+    __asm__ volatile (
+        "ld    3, 0x0(%0) ;"
+        "cmpdi 3, 0x4eed ; " // Check canary
+        "bne   . ; "
+        "ld    0,  0x08(%0) ;"
+        "ld    1,  0x10(%0) ;"
+        "ld    2,  0x18(%0) ;"
+        "ld    14, 0x20(%0) ;"
+        "ld    15, 0x28(%0) ;"
+        "ld    16, 0x30(%0) ;"
+        "ld    17, 0x38(%0) ;"
+        "ld    18, 0x40(%0) ;"
+        "ld    19, 0x48(%0) ;"
+        "ld    20, 0x50(%0) ;"
+        "ld    21, 0x58(%0) ;"
+        "ld    22, 0x60(%0) ;"
+        "ld    23, 0x68(%0) ;"
+        "ld    24, 0x70(%0) ;"
+        "ld    25, 0x78(%0) ;"
+        "ld    26, 0x80(%0) ;"
+        "ld    27, 0x88(%0) ;"
+        "ld    28, 0x90(%0) ;"
+        "ld    29, 0x98(%0) ;"
+        "ld    30, 0xA0(%0) ;"
+        "ld    31, 0xA8(%0) ;"
+        "ld    3,  0xB0(%0) ;"
+        "mtcr  3 ;"
+        "ld    3, 0xB8(%0) ;"
+        "mtlr  3 ; "
+        "li    3, 1;"
+        "blr ;"
+        :
+        : "r" (&top->regs)
+        :
+        );
 
     MP_UNREACHABLE;
 }
diff --git a/py/nlrthumb.c b/py/nlrthumb.c
index bc30388..a8ffecc 100644
--- a/py/nlrthumb.c
+++ b/py/nlrthumb.c
@@ -39,51 +39,51 @@
 __attribute__((naked)) unsigned int nlr_push(nlr_buf_t *nlr) {
 
     __asm volatile (
-    "str    r4, [r0, #12]       \n" // store r4 into nlr_buf
-    "str    r5, [r0, #16]       \n" // store r5 into nlr_buf
-    "str    r6, [r0, #20]       \n" // store r6 into nlr_buf
-    "str    r7, [r0, #24]       \n" // store r7 into nlr_buf
+        "str    r4, [r0, #12]       \n" // store r4 into nlr_buf
+        "str    r5, [r0, #16]       \n" // store r5 into nlr_buf
+        "str    r6, [r0, #20]       \n" // store r6 into nlr_buf
+        "str    r7, [r0, #24]       \n" // store r7 into nlr_buf
 
-#if !defined(__thumb2__)
-    "mov    r1, r8              \n"
-    "str    r1, [r0, #28]       \n" // store r8 into nlr_buf
-    "mov    r1, r9              \n"
-    "str    r1, [r0, #32]       \n" // store r9 into nlr_buf
-    "mov    r1, r10             \n"
-    "str    r1, [r0, #36]       \n" // store r10 into nlr_buf
-    "mov    r1, r11             \n"
-    "str    r1, [r0, #40]       \n" // store r11 into nlr_buf
-    "mov    r1, r13             \n"
-    "str    r1, [r0, #44]       \n" // store r13=sp into nlr_buf
-    "mov    r1, lr              \n"
-    "str    r1, [r0, #8]        \n" // store lr into nlr_buf
-#else
-    "str    r8, [r0, #28]       \n" // store r8 into nlr_buf
-    "str    r9, [r0, #32]       \n" // store r9 into nlr_buf
-    "str    r10, [r0, #36]      \n" // store r10 into nlr_buf
-    "str    r11, [r0, #40]      \n" // store r11 into nlr_buf
-    "str    r13, [r0, #44]      \n" // store r13=sp into nlr_buf
-    #if MICROPY_NLR_NUM_REGS == 16
-    "vstr   d8, [r0, #48]       \n" // store s16-s17 into nlr_buf
-    "vstr   d9, [r0, #56]       \n" // store s18-s19 into nlr_buf
-    "vstr   d10, [r0, #64]      \n" // store s20-s21 into nlr_buf
-    #endif
-    "str    lr, [r0, #8]        \n" // store lr into nlr_buf
-#endif
+        #if !defined(__thumb2__)
+        "mov    r1, r8              \n"
+        "str    r1, [r0, #28]       \n" // store r8 into nlr_buf
+        "mov    r1, r9              \n"
+        "str    r1, [r0, #32]       \n" // store r9 into nlr_buf
+        "mov    r1, r10             \n"
+        "str    r1, [r0, #36]       \n" // store r10 into nlr_buf
+        "mov    r1, r11             \n"
+        "str    r1, [r0, #40]       \n" // store r11 into nlr_buf
+        "mov    r1, r13             \n"
+        "str    r1, [r0, #44]       \n" // store r13=sp into nlr_buf
+        "mov    r1, lr              \n"
+        "str    r1, [r0, #8]        \n" // store lr into nlr_buf
+        #else
+        "str    r8, [r0, #28]       \n" // store r8 into nlr_buf
+        "str    r9, [r0, #32]       \n" // store r9 into nlr_buf
+        "str    r10, [r0, #36]      \n" // store r10 into nlr_buf
+        "str    r11, [r0, #40]      \n" // store r11 into nlr_buf
+        "str    r13, [r0, #44]      \n" // store r13=sp into nlr_buf
+        #if MICROPY_NLR_NUM_REGS == 16
+        "vstr   d8, [r0, #48]       \n" // store s16-s17 into nlr_buf
+        "vstr   d9, [r0, #56]       \n" // store s18-s19 into nlr_buf
+        "vstr   d10, [r0, #64]      \n" // store s20-s21 into nlr_buf
+        #endif
+        "str    lr, [r0, #8]        \n" // store lr into nlr_buf
+        #endif
 
-#if !defined(__thumb2__)
-    "ldr    r1, nlr_push_tail_var \n"
-    "bx     r1                  \n" // do the rest in C
-    ".align 2                   \n"
-    "nlr_push_tail_var: .word nlr_push_tail \n"
-#else
-    #if defined(__APPLE__) || defined(__MACH__)
-    "b      _nlr_push_tail      \n" // do the rest in C
-    #else
-    "b      nlr_push_tail       \n" // do the rest in C
-    #endif
-#endif
-    );
+        #if !defined(__thumb2__)
+        "ldr    r1, nlr_push_tail_var \n"
+        "bx     r1                  \n" // do the rest in C
+        ".align 2                   \n"
+        "nlr_push_tail_var: .word nlr_push_tail \n"
+        #else
+        #if defined(__APPLE__) || defined(__MACH__)
+        "b      _nlr_push_tail      \n" // do the rest in C
+        #else
+        "b      nlr_push_tail       \n" // do the rest in C
+        #endif
+        #endif
+        );
 
     #if !defined(__clang__) && defined(__GNUC__) && (__GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 8))
     // Older versions of gcc give an error when naked functions don't return a value
@@ -96,44 +96,44 @@
     MP_NLR_JUMP_HEAD(val, top)
 
     __asm volatile (
-    "mov    r0, %0              \n" // r0 points to nlr_buf
-    "ldr    r4, [r0, #12]       \n" // load r4 from nlr_buf
-    "ldr    r5, [r0, #16]       \n" // load r5 from nlr_buf
-    "ldr    r6, [r0, #20]       \n" // load r6 from nlr_buf
-    "ldr    r7, [r0, #24]       \n" // load r7 from nlr_buf
+        "mov    r0, %0              \n" // r0 points to nlr_buf
+        "ldr    r4, [r0, #12]       \n" // load r4 from nlr_buf
+        "ldr    r5, [r0, #16]       \n" // load r5 from nlr_buf
+        "ldr    r6, [r0, #20]       \n" // load r6 from nlr_buf
+        "ldr    r7, [r0, #24]       \n" // load r7 from nlr_buf
 
-#if !defined(__thumb2__)
-    "ldr    r1, [r0, #28]       \n" // load r8 from nlr_buf
-    "mov    r8, r1              \n"
-    "ldr    r1, [r0, #32]       \n" // load r9 from nlr_buf
-    "mov    r9, r1              \n"
-    "ldr    r1, [r0, #36]       \n" // load r10 from nlr_buf
-    "mov    r10, r1             \n"
-    "ldr    r1, [r0, #40]       \n" // load r11 from nlr_buf
-    "mov    r11, r1             \n"
-    "ldr    r1, [r0, #44]       \n" // load r13=sp from nlr_buf
-    "mov    r13, r1             \n"
-    "ldr    r1, [r0, #8]        \n" // load lr from nlr_buf
-    "mov    lr, r1              \n"
-#else
-    "ldr    r8, [r0, #28]       \n" // load r8 from nlr_buf
-    "ldr    r9, [r0, #32]       \n" // load r9 from nlr_buf
-    "ldr    r10, [r0, #36]      \n" // load r10 from nlr_buf
-    "ldr    r11, [r0, #40]      \n" // load r11 from nlr_buf
-    "ldr    r13, [r0, #44]      \n" // load r13=sp from nlr_buf
-    #if MICROPY_NLR_NUM_REGS == 16
-    "vldr   d8, [r0, #48]       \n" // load s16-s17 from nlr_buf
-    "vldr   d9, [r0, #56]       \n" // load s18-s19 from nlr_buf
-    "vldr   d10, [r0, #64]      \n" // load s20-s21 from nlr_buf
-    #endif
-    "ldr    lr, [r0, #8]        \n" // load lr from nlr_buf
-#endif
-    "movs   r0, #1              \n" // return 1, non-local return
-    "bx     lr                  \n" // return
-    :                               // output operands
-    : "r"(top)                      // input operands
-    :                               // clobbered registers
-    );
+        #if !defined(__thumb2__)
+        "ldr    r1, [r0, #28]       \n" // load r8 from nlr_buf
+        "mov    r8, r1              \n"
+        "ldr    r1, [r0, #32]       \n" // load r9 from nlr_buf
+        "mov    r9, r1              \n"
+        "ldr    r1, [r0, #36]       \n" // load r10 from nlr_buf
+        "mov    r10, r1             \n"
+        "ldr    r1, [r0, #40]       \n" // load r11 from nlr_buf
+        "mov    r11, r1             \n"
+        "ldr    r1, [r0, #44]       \n" // load r13=sp from nlr_buf
+        "mov    r13, r1             \n"
+        "ldr    r1, [r0, #8]        \n" // load lr from nlr_buf
+        "mov    lr, r1              \n"
+        #else
+        "ldr    r8, [r0, #28]       \n" // load r8 from nlr_buf
+        "ldr    r9, [r0, #32]       \n" // load r9 from nlr_buf
+        "ldr    r10, [r0, #36]      \n" // load r10 from nlr_buf
+        "ldr    r11, [r0, #40]      \n" // load r11 from nlr_buf
+        "ldr    r13, [r0, #44]      \n" // load r13=sp from nlr_buf
+        #if MICROPY_NLR_NUM_REGS == 16
+        "vldr   d8, [r0, #48]       \n" // load s16-s17 from nlr_buf
+        "vldr   d9, [r0, #56]       \n" // load s18-s19 from nlr_buf
+        "vldr   d10, [r0, #64]      \n" // load s20-s21 from nlr_buf
+        #endif
+        "ldr    lr, [r0, #8]        \n" // load lr from nlr_buf
+        #endif
+        "movs   r0, #1              \n" // return 1, non-local return
+        "bx     lr                  \n" // return
+        :                           // output operands
+        : "r" (top)                 // input operands
+        :                           // clobbered registers
+        );
 
     MP_UNREACHABLE
 }
diff --git a/py/nlrx64.c b/py/nlrx64.c
index 95496b3..eb39dad 100644
--- a/py/nlrx64.c
+++ b/py/nlrx64.c
@@ -41,41 +41,41 @@
     #if MICROPY_NLR_OS_WINDOWS
 
     __asm volatile (
-    "movq   (%rsp), %rax        \n" // load return %rip
-    "movq   %rax, 16(%rcx)      \n" // store %rip into nlr_buf
-    "movq   %rbp, 24(%rcx)      \n" // store %rbp into nlr_buf
-    "movq   %rsp, 32(%rcx)      \n" // store %rsp into nlr_buf
-    "movq   %rbx, 40(%rcx)      \n" // store %rbx into nlr_buf
-    "movq   %r12, 48(%rcx)      \n" // store %r12 into nlr_buf
-    "movq   %r13, 56(%rcx)      \n" // store %r13 into nlr_buf
-    "movq   %r14, 64(%rcx)      \n" // store %r14 into nlr_buf
-    "movq   %r15, 72(%rcx)      \n" // store %r15 into nlr_buf
-    "movq   %rdi, 80(%rcx)      \n" // store %rdr into nlr_buf
-    "movq   %rsi, 88(%rcx)      \n" // store %rsi into nlr_buf
-    "jmp    nlr_push_tail       \n" // do the rest in C
-    );
+        "movq   (%rsp), %rax        \n" // load return %rip
+        "movq   %rax, 16(%rcx)      \n" // store %rip into nlr_buf
+        "movq   %rbp, 24(%rcx)      \n" // store %rbp into nlr_buf
+        "movq   %rsp, 32(%rcx)      \n" // store %rsp into nlr_buf
+        "movq   %rbx, 40(%rcx)      \n" // store %rbx into nlr_buf
+        "movq   %r12, 48(%rcx)      \n" // store %r12 into nlr_buf
+        "movq   %r13, 56(%rcx)      \n" // store %r13 into nlr_buf
+        "movq   %r14, 64(%rcx)      \n" // store %r14 into nlr_buf
+        "movq   %r15, 72(%rcx)      \n" // store %r15 into nlr_buf
+        "movq   %rdi, 80(%rcx)      \n" // store %rdr into nlr_buf
+        "movq   %rsi, 88(%rcx)      \n" // store %rsi into nlr_buf
+        "jmp    nlr_push_tail       \n" // do the rest in C
+        );
 
     #else
 
     __asm volatile (
-    #if defined(__APPLE__) || defined(__MACH__)
-    "pop    %rbp                \n" // undo function's prelude
-    #endif
-    "movq   (%rsp), %rax        \n" // load return %rip
-    "movq   %rax, 16(%rdi)      \n" // store %rip into nlr_buf
-    "movq   %rbp, 24(%rdi)      \n" // store %rbp into nlr_buf
-    "movq   %rsp, 32(%rdi)      \n" // store %rsp into nlr_buf
-    "movq   %rbx, 40(%rdi)      \n" // store %rbx into nlr_buf
-    "movq   %r12, 48(%rdi)      \n" // store %r12 into nlr_buf
-    "movq   %r13, 56(%rdi)      \n" // store %r13 into nlr_buf
-    "movq   %r14, 64(%rdi)      \n" // store %r14 into nlr_buf
-    "movq   %r15, 72(%rdi)      \n" // store %r15 into nlr_buf
-    #if defined(__APPLE__) || defined(__MACH__)
-    "jmp    _nlr_push_tail      \n" // do the rest in C
-    #else
-    "jmp    nlr_push_tail       \n" // do the rest in C
-    #endif
-    );
+        #if defined(__APPLE__) || defined(__MACH__)
+        "pop    %rbp                \n" // undo function's prelude
+        #endif
+        "movq   (%rsp), %rax        \n" // load return %rip
+        "movq   %rax, 16(%rdi)      \n" // store %rip into nlr_buf
+        "movq   %rbp, 24(%rdi)      \n" // store %rbp into nlr_buf
+        "movq   %rsp, 32(%rdi)      \n" // store %rsp into nlr_buf
+        "movq   %rbx, 40(%rdi)      \n" // store %rbx into nlr_buf
+        "movq   %r12, 48(%rdi)      \n" // store %r12 into nlr_buf
+        "movq   %r13, 56(%rdi)      \n" // store %r13 into nlr_buf
+        "movq   %r14, 64(%rdi)      \n" // store %r14 into nlr_buf
+        "movq   %r15, 72(%rdi)      \n" // store %r15 into nlr_buf
+        #if defined(__APPLE__) || defined(__MACH__)
+        "jmp    _nlr_push_tail      \n" // do the rest in C
+        #else
+        "jmp    nlr_push_tail       \n" // do the rest in C
+        #endif
+        );
 
     #endif
 
@@ -86,27 +86,27 @@
     MP_NLR_JUMP_HEAD(val, top)
 
     __asm volatile (
-    "movq   %0, %%rcx           \n" // %rcx points to nlr_buf
-    #if MICROPY_NLR_OS_WINDOWS
-    "movq   88(%%rcx), %%rsi    \n" // load saved %rsi
-    "movq   80(%%rcx), %%rdi    \n" // load saved %rdr
-    #endif
-    "movq   72(%%rcx), %%r15    \n" // load saved %r15
-    "movq   64(%%rcx), %%r14    \n" // load saved %r14
-    "movq   56(%%rcx), %%r13    \n" // load saved %r13
-    "movq   48(%%rcx), %%r12    \n" // load saved %r12
-    "movq   40(%%rcx), %%rbx    \n" // load saved %rbx
-    "movq   32(%%rcx), %%rsp    \n" // load saved %rsp
-    "movq   24(%%rcx), %%rbp    \n" // load saved %rbp
-    "movq   16(%%rcx), %%rax    \n" // load saved %rip
-    "movq   %%rax, (%%rsp)      \n" // store saved %rip to stack
-    "xorq   %%rax, %%rax        \n" // clear return register
-    "inc    %%al                \n" // increase to make 1, non-local return
-    "ret                        \n" // return
-    :                               // output operands
-    : "r"(top)                      // input operands
-    :                               // clobbered registers
-    );
+        "movq   %0, %%rcx           \n" // %rcx points to nlr_buf
+        #if MICROPY_NLR_OS_WINDOWS
+        "movq   88(%%rcx), %%rsi    \n" // load saved %rsi
+        "movq   80(%%rcx), %%rdi    \n" // load saved %rdr
+        #endif
+        "movq   72(%%rcx), %%r15    \n" // load saved %r15
+        "movq   64(%%rcx), %%r14    \n" // load saved %r14
+        "movq   56(%%rcx), %%r13    \n" // load saved %r13
+        "movq   48(%%rcx), %%r12    \n" // load saved %r12
+        "movq   40(%%rcx), %%rbx    \n" // load saved %rbx
+        "movq   32(%%rcx), %%rsp    \n" // load saved %rsp
+        "movq   24(%%rcx), %%rbp    \n" // load saved %rbp
+        "movq   16(%%rcx), %%rax    \n" // load saved %rip
+        "movq   %%rax, (%%rsp)      \n" // store saved %rip to stack
+        "xorq   %%rax, %%rax        \n" // clear return register
+        "inc    %%al                \n" // increase to make 1, non-local return
+        "ret                        \n" // return
+        :                           // output operands
+        : "r" (top)                 // input operands
+        :                           // clobbered registers
+        );
 
     MP_UNREACHABLE
 }
diff --git a/py/nlrx86.c b/py/nlrx86.c
index 461b459..f658d41 100644
--- a/py/nlrx86.c
+++ b/py/nlrx86.c
@@ -34,7 +34,7 @@
 //  ebx, esi, edi, ebp, esp, eip
 
 #if MICROPY_NLR_OS_WINDOWS
-unsigned int nlr_push_tail(nlr_buf_t *nlr) asm("nlr_push_tail");
+unsigned int nlr_push_tail(nlr_buf_t *nlr) asm ("nlr_push_tail");
 #else
 __attribute__((used)) unsigned int nlr_push_tail(nlr_buf_t *nlr);
 #endif
@@ -59,19 +59,19 @@
     (void)nlr;
 
     __asm volatile (
-    #if UNDO_PRELUDE
-    "pop    %ebp                \n" // undo function's prelude
-    #endif
-    "mov    4(%esp), %edx       \n" // load nlr_buf
-    "mov    (%esp), %eax        \n" // load return %eip
-    "mov    %eax, 8(%edx)       \n" // store %eip into nlr_buf
-    "mov    %ebp, 12(%edx)      \n" // store %ebp into nlr_buf
-    "mov    %esp, 16(%edx)      \n" // store %esp into nlr_buf
-    "mov    %ebx, 20(%edx)      \n" // store %ebx into nlr_buf
-    "mov    %edi, 24(%edx)      \n" // store %edi into nlr_buf
-    "mov    %esi, 28(%edx)      \n" // store %esi into nlr_buf
-    "jmp    nlr_push_tail       \n" // do the rest in C
-    );
+        #if UNDO_PRELUDE
+        "pop    %ebp                \n" // undo function's prelude
+        #endif
+        "mov    4(%esp), %edx       \n" // load nlr_buf
+        "mov    (%esp), %eax        \n" // load return %eip
+        "mov    %eax, 8(%edx)       \n" // store %eip into nlr_buf
+        "mov    %ebp, 12(%edx)      \n" // store %ebp into nlr_buf
+        "mov    %esp, 16(%edx)      \n" // store %esp into nlr_buf
+        "mov    %ebx, 20(%edx)      \n" // store %ebx into nlr_buf
+        "mov    %edi, 24(%edx)      \n" // store %edi into nlr_buf
+        "mov    %esi, 28(%edx)      \n" // store %esi into nlr_buf
+        "jmp    nlr_push_tail       \n" // do the rest in C
+        );
 
     #if !USE_NAKED
     return 0; // needed to silence compiler warning
@@ -82,21 +82,21 @@
     MP_NLR_JUMP_HEAD(val, top)
 
     __asm volatile (
-    "mov    %0, %%edx           \n" // %edx points to nlr_buf
-    "mov    28(%%edx), %%esi    \n" // load saved %esi
-    "mov    24(%%edx), %%edi    \n" // load saved %edi
-    "mov    20(%%edx), %%ebx    \n" // load saved %ebx
-    "mov    16(%%edx), %%esp    \n" // load saved %esp
-    "mov    12(%%edx), %%ebp    \n" // load saved %ebp
-    "mov    8(%%edx), %%eax     \n" // load saved %eip
-    "mov    %%eax, (%%esp)      \n" // store saved %eip to stack
-    "xor    %%eax, %%eax        \n" // clear return register
-    "inc    %%al                \n" // increase to make 1, non-local return
-    "ret                        \n" // return
-    :                               // output operands
-    : "r"(top)                      // input operands
-    :                               // clobbered registers
-    );
+        "mov    %0, %%edx           \n" // %edx points to nlr_buf
+        "mov    28(%%edx), %%esi    \n" // load saved %esi
+        "mov    24(%%edx), %%edi    \n" // load saved %edi
+        "mov    20(%%edx), %%ebx    \n" // load saved %ebx
+        "mov    16(%%edx), %%esp    \n" // load saved %esp
+        "mov    12(%%edx), %%ebp    \n" // load saved %ebp
+        "mov    8(%%edx), %%eax     \n" // load saved %eip
+        "mov    %%eax, (%%esp)      \n" // store saved %eip to stack
+        "xor    %%eax, %%eax        \n" // clear return register
+        "inc    %%al                \n" // increase to make 1, non-local return
+        "ret                        \n" // return
+        :                           // output operands
+        : "r" (top)                 // input operands
+        :                           // clobbered registers
+        );
 
     MP_UNREACHABLE
 }
diff --git a/py/nlrxtensa.c b/py/nlrxtensa.c
index 895b202..abe9042 100644
--- a/py/nlrxtensa.c
+++ b/py/nlrxtensa.c
@@ -39,18 +39,18 @@
 unsigned int nlr_push(nlr_buf_t *nlr) {
 
     __asm volatile (
-    "s32i.n  a0, a2, 8          \n" // save regs...
-    "s32i.n  a1, a2, 12         \n"
-    "s32i.n  a8, a2, 16         \n"
-    "s32i.n  a9, a2, 20         \n"
-    "s32i.n  a10, a2, 24        \n"
-    "s32i.n  a11, a2, 28        \n"
-    "s32i.n  a12, a2, 32        \n"
-    "s32i.n  a13, a2, 36        \n"
-    "s32i.n  a14, a2, 40        \n"
-    "s32i.n  a15, a2, 44        \n"
-    "j      nlr_push_tail       \n" // do the rest in C
-    );
+        "s32i.n  a0, a2, 8          \n" // save regs...
+        "s32i.n  a1, a2, 12         \n"
+        "s32i.n  a8, a2, 16         \n"
+        "s32i.n  a9, a2, 20         \n"
+        "s32i.n  a10, a2, 24        \n"
+        "s32i.n  a11, a2, 28        \n"
+        "s32i.n  a12, a2, 32        \n"
+        "s32i.n  a13, a2, 36        \n"
+        "s32i.n  a14, a2, 40        \n"
+        "s32i.n  a15, a2, 44        \n"
+        "j      nlr_push_tail       \n" // do the rest in C
+        );
 
     return 0; // needed to silence compiler warning
 }
@@ -59,23 +59,23 @@
     MP_NLR_JUMP_HEAD(val, top)
 
     __asm volatile (
-    "mov.n   a2, %0             \n" // a2 points to nlr_buf
-    "l32i.n  a0, a2, 8          \n" // restore regs...
-    "l32i.n  a1, a2, 12         \n"
-    "l32i.n  a8, a2, 16         \n"
-    "l32i.n  a9, a2, 20         \n"
-    "l32i.n  a10, a2, 24        \n"
-    "l32i.n  a11, a2, 28        \n"
-    "l32i.n  a12, a2, 32        \n"
-    "l32i.n  a13, a2, 36        \n"
-    "l32i.n  a14, a2, 40        \n"
-    "l32i.n  a15, a2, 44        \n"
-    "movi.n a2, 1               \n" // return 1, non-local return
-    "ret.n                      \n" // return
-    :                               // output operands
-    : "r"(top)                      // input operands
-    :                               // clobbered registers
-    );
+        "mov.n   a2, %0             \n" // a2 points to nlr_buf
+        "l32i.n  a0, a2, 8          \n" // restore regs...
+        "l32i.n  a1, a2, 12         \n"
+        "l32i.n  a8, a2, 16         \n"
+        "l32i.n  a9, a2, 20         \n"
+        "l32i.n  a10, a2, 24        \n"
+        "l32i.n  a11, a2, 28        \n"
+        "l32i.n  a12, a2, 32        \n"
+        "l32i.n  a13, a2, 36        \n"
+        "l32i.n  a14, a2, 40        \n"
+        "l32i.n  a15, a2, 44        \n"
+        "movi.n a2, 1               \n" // return 1, non-local return
+        "ret.n                      \n" // return
+        :                           // output operands
+        : "r" (top)                 // input operands
+        :                           // clobbered registers
+        );
 
     MP_UNREACHABLE
 }
diff --git a/py/obj.c b/py/obj.c
index eef24a9..6e68180 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -77,11 +77,11 @@
         return &mp_type_int;
     } else if (mp_obj_is_qstr(o_in)) {
         return &mp_type_str;
-    #if MICROPY_PY_BUILTINS_FLOAT && ( \
-        MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D)
+        #if MICROPY_PY_BUILTINS_FLOAT && ( \
+            MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D)
     } else if (mp_obj_is_float(o_in)) {
         return &mp_type_float;
-    #endif
+        #endif
     #if MICROPY_OBJ_IMMEDIATE_OBJS
     } else if (mp_obj_is_immediate_obj(o_in)) {
         static const mp_obj_type_t *const types[2] = {&mp_type_NoneType, &mp_type_bool};
@@ -102,15 +102,15 @@
 void mp_obj_print_helper(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     // There can be data structures nested too deep, or just recursive
     MP_STACK_CHECK();
-#ifndef NDEBUG
+    #ifndef NDEBUG
     if (o_in == MP_OBJ_NULL) {
         mp_print_str(print, "(nil)");
         return;
     }
-#endif
+    #endif
     const mp_obj_type_t *type = mp_obj_get_type(o_in);
     if (type->print != NULL) {
-        type->print((mp_print_t*)print, o_in, kind);
+        type->print((mp_print_t *)print, o_in, kind);
     } else {
         mp_printf(print, "<%q>", type->name);
     }
@@ -129,11 +129,11 @@
             assert(n % 3 == 0);
             mp_print_str(print, "Traceback (most recent call last):\n");
             for (int i = n - 3; i >= 0; i -= 3) {
-#if MICROPY_ENABLE_SOURCE_LINE
+                #if MICROPY_ENABLE_SOURCE_LINE
                 mp_printf(print, "  File \"%q\", line %d", values[i], (int)values[i + 1]);
-#else
+                #else
                 mp_printf(print, "  File \"%q\"", values[i]);
-#endif
+                #endif
                 // the block name can be NULL if it's unknown
                 qstr block = values[i + 2];
                 if (block == MP_QSTRnull) {
@@ -507,10 +507,10 @@
 // may return MP_OBJ_NULL
 mp_obj_t mp_obj_len_maybe(mp_obj_t o_in) {
     if (
-#if !MICROPY_PY_BUILTINS_STR_UNICODE
+        #if !MICROPY_PY_BUILTINS_STR_UNICODE
         // It's simple - unicode is slow, non-unicode is fast
         mp_obj_is_str(o_in) ||
-#endif
+        #endif
         mp_obj_is_type(o_in, &mp_type_bytes)) {
         GET_STR_LEN(o_in, l);
         return MP_OBJ_NEW_SMALL_INT(l);
@@ -589,7 +589,9 @@
 
 mp_obj_t mp_generic_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     switch (op) {
-        case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
-        default: return MP_OBJ_NULL; // op not supported
+        case MP_UNARY_OP_HASH:
+            return MP_OBJ_NEW_SMALL_INT((mp_uint_t)o_in);
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
diff --git a/py/obj.h b/py/obj.h
index 3e910eb..e3299cb 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -66,13 +66,13 @@
 // as many as we can to MP_OBJ_NULL because it's cheaper to load/compare 0.
 
 #if MICROPY_DEBUG_MP_OBJ_SENTINELS
-#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void*)0))
-#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void*)4))
-#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void*)8))
+#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void *)0))
+#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void *)4))
+#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void *)8))
 #else
-#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void*)0))
-#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void*)0))
-#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void*)4))
+#define MP_OBJ_NULL             (MP_OBJ_FROM_PTR((void *)0))
+#define MP_OBJ_STOP_ITERATION   (MP_OBJ_FROM_PTR((void *)0))
+#define MP_OBJ_SENTINEL         (MP_OBJ_FROM_PTR((void *)4))
 #endif
 
 // These macros/inline functions operate on objects and depend on the
@@ -81,18 +81,21 @@
 
 #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_A
 
-static inline bool mp_obj_is_small_int(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 1) != 0); }
+static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 1) != 0;
+}
 #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1)
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
 
-static inline bool mp_obj_is_qstr(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 7) == 2); }
+static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 7) == 2;
+}
 #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3)
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 2))
 
-static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 7) == 6); }
+static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 7) == 6;
+}
 #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3)
 #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 3) | 6))
 
@@ -107,23 +110,27 @@
 mp_obj_t mp_obj_new_float(mp_float_t value);
 #endif
 
-static inline bool mp_obj_is_obj(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 3) == 0); }
+static inline bool mp_obj_is_obj(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 3) == 0;
+}
 
 #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_B
 
-static inline bool mp_obj_is_small_int(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 3) == 1); }
+static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 3) == 1;
+}
 #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 2)
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 2) | 1))
 
-static inline bool mp_obj_is_qstr(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 7) == 3); }
+static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 7) == 3;
+}
 #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 3)
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 3) | 3))
 
-static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 7) == 7); }
+static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 7) == 7;
+}
 #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 3)
 #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 3) | 7))
 
@@ -138,13 +145,15 @@
 mp_obj_t mp_obj_new_float(mp_float_t value);
 #endif
 
-static inline bool mp_obj_is_obj(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 1) == 0); }
+static inline bool mp_obj_is_obj(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 1) == 0;
+}
 
 #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
 
-static inline bool mp_obj_is_small_int(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 1) != 0); }
+static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 1) != 0;
+}
 #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)(o)) >> 1)
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_uint_t)(small_int)) << 1) | 1))
 
@@ -152,8 +161,9 @@
 #define mp_const_float_e MP_ROM_PTR((mp_obj_t)(((0x402df854 & ~3) | 2) + 0x80800000))
 #define mp_const_float_pi MP_ROM_PTR((mp_obj_t)(((0x40490fdb & ~3) | 2) + 0x80800000))
 
-static inline bool mp_obj_is_float(mp_const_obj_t o)
-    { return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0xff800007) != 0x00000006; }
+static inline bool mp_obj_is_float(mp_const_obj_t o) {
+    return (((mp_uint_t)(o)) & 3) == 2 && (((mp_uint_t)(o)) & 0xff800007) != 0x00000006;
+}
 static inline mp_float_t mp_obj_float_get(mp_const_obj_t o) {
     union {
         mp_float_t f;
@@ -170,33 +180,39 @@
 }
 #endif
 
-static inline bool mp_obj_is_qstr(mp_const_obj_t o)
-    { return (((mp_uint_t)(o)) & 0xff80000f) == 0x00000006; }
+static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
+    return (((mp_uint_t)(o)) & 0xff80000f) == 0x00000006;
+}
 #define MP_OBJ_QSTR_VALUE(o) (((mp_uint_t)(o)) >> 4)
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 4) | 0x00000006))
 
-static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o)
-    { return (((mp_uint_t)(o)) & 0xff80000f) == 0x0000000e; }
+static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
+    return (((mp_uint_t)(o)) & 0xff80000f) == 0x0000000e;
+}
 #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) (((mp_uint_t)(o)) >> 4)
 #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) ((mp_obj_t)(((val) << 4) | 0xe))
 
-static inline bool mp_obj_is_obj(mp_const_obj_t o)
-    { return ((((mp_int_t)(o)) & 3) == 0); }
+static inline bool mp_obj_is_obj(mp_const_obj_t o) {
+    return (((mp_int_t)(o)) & 3) == 0;
+}
 
 #elif MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
 
-static inline bool mp_obj_is_small_int(mp_const_obj_t o)
-    { return ((((uint64_t)(o)) & 0xffff000000000000) == 0x0001000000000000); }
+static inline bool mp_obj_is_small_int(mp_const_obj_t o) {
+    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0001000000000000;
+}
 #define MP_OBJ_SMALL_INT_VALUE(o) (((mp_int_t)((o) << 16)) >> 17)
 #define MP_OBJ_NEW_SMALL_INT(small_int) (((((uint64_t)(small_int)) & 0x7fffffffffff) << 1) | 0x0001000000000001)
 
-static inline bool mp_obj_is_qstr(mp_const_obj_t o)
-    { return ((((uint64_t)(o)) & 0xffff000000000000) == 0x0002000000000000); }
+static inline bool mp_obj_is_qstr(mp_const_obj_t o) {
+    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0002000000000000;
+}
 #define MP_OBJ_QSTR_VALUE(o) ((((uint32_t)(o)) >> 1) & 0xffffffff)
 #define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)(((uint64_t)(((uint32_t)(qst)) << 1)) | 0x0002000000000001))
 
-static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o)
-    { return ((((uint64_t)(o)) & 0xffff000000000000) == 0x0003000000000000); }
+static inline bool mp_obj_is_immediate_obj(mp_const_obj_t o) {
+    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0003000000000000;
+}
 #define MP_OBJ_IMMEDIATE_OBJ_VALUE(o) ((((uint32_t)(o)) >> 46) & 3)
 #define MP_OBJ_NEW_IMMEDIATE_OBJ(val) (((uint64_t)(val) << 46) | 0x0003000000000000)
 
@@ -228,13 +244,17 @@
 }
 #endif
 
-static inline bool mp_obj_is_obj(mp_const_obj_t o)
-    { return ((((uint64_t)(o)) & 0xffff000000000000) == 0x0000000000000000); }
-#define MP_OBJ_TO_PTR(o) ((void*)(uintptr_t)(o))
+static inline bool mp_obj_is_obj(mp_const_obj_t o) {
+    return (((uint64_t)(o)) & 0xffff000000000000) == 0x0000000000000000;
+}
+#define MP_OBJ_TO_PTR(o) ((void *)(uintptr_t)(o))
 #define MP_OBJ_FROM_PTR(p) ((mp_obj_t)((uintptr_t)(p)))
 
 // rom object storage needs special handling to widen 32-bit pointer to 64-bits
-typedef union _mp_rom_obj_t { uint64_t u64; struct { const void *lo, *hi; } u32; } mp_rom_obj_t;
+typedef union _mp_rom_obj_t { uint64_t u64;
+                              struct { const void *lo, *hi;
+                              } u32;
+} mp_rom_obj_t;
 #define MP_ROM_INT(i) {MP_OBJ_NEW_SMALL_INT(i)}
 #define MP_ROM_QSTR(q) {MP_OBJ_NEW_QSTR(q)}
 #if MP_ENDIANNESS_LITTLE
@@ -252,7 +272,7 @@
 
 // Cast mp_obj_t to object pointer
 #ifndef MP_OBJ_TO_PTR
-#define MP_OBJ_TO_PTR(o) ((void*)o)
+#define MP_OBJ_TO_PTR(o) ((void *)o)
 #endif
 
 // Cast object pointer to mp_obj_t
@@ -309,25 +329,25 @@
 
 #define MP_DEFINE_CONST_FUN_OBJ_0(obj_name, fun_name) \
     const mp_obj_fun_builtin_fixed_t obj_name = \
-        {{&mp_type_fun_builtin_0}, .fun._0 = fun_name}
+    {{&mp_type_fun_builtin_0}, .fun._0 = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_1(obj_name, fun_name) \
     const mp_obj_fun_builtin_fixed_t obj_name = \
-        {{&mp_type_fun_builtin_1}, .fun._1 = fun_name}
+    {{&mp_type_fun_builtin_1}, .fun._1 = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_2(obj_name, fun_name) \
     const mp_obj_fun_builtin_fixed_t obj_name = \
-        {{&mp_type_fun_builtin_2}, .fun._2 = fun_name}
+    {{&mp_type_fun_builtin_2}, .fun._2 = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_3(obj_name, fun_name) \
     const mp_obj_fun_builtin_fixed_t obj_name = \
-        {{&mp_type_fun_builtin_3}, .fun._3 = fun_name}
+    {{&mp_type_fun_builtin_3}, .fun._3 = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_VAR(obj_name, n_args_min, fun_name) \
     const mp_obj_fun_builtin_var_t obj_name = \
-        {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, false), .fun.var = fun_name}
+    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, false), .fun.var = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(obj_name, n_args_min, n_args_max, fun_name) \
     const mp_obj_fun_builtin_var_t obj_name = \
-        {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, false), .fun.var = fun_name}
+    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, n_args_max, false), .fun.var = fun_name}
 #define MP_DEFINE_CONST_FUN_OBJ_KW(obj_name, n_args_min, fun_name) \
     const mp_obj_fun_builtin_var_t obj_name = \
-        {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, true), .fun.kw = fun_name}
+    {{&mp_type_fun_builtin_var}, MP_OBJ_FUN_MAKE_SIG(n_args_min, MP_OBJ_FUN_ARGS_MAX, true), .fun.kw = fun_name}
 
 // These macros are used to define constant map/dict objects
 // You can put "static" in front of the definition to make it local
@@ -339,7 +359,7 @@
         .is_ordered = 1, \
         .used = MP_ARRAY_SIZE(table_name), \
         .alloc = MP_ARRAY_SIZE(table_name), \
-        .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)table_name, \
+        .table = (mp_map_elem_t *)(mp_rom_map_elem_t *)table_name, \
     }
 
 #define MP_DEFINE_CONST_DICT(dict_name, table_name) \
@@ -351,7 +371,7 @@
             .is_ordered = 1, \
             .used = MP_ARRAY_SIZE(table_name), \
             .alloc = MP_ARRAY_SIZE(table_name), \
-            .table = (mp_map_elem_t*)(mp_rom_map_elem_t*)table_name, \
+            .table = (mp_map_elem_t *)(mp_rom_map_elem_t *)table_name, \
         }, \
     }
 
@@ -402,7 +422,9 @@
 
 extern const mp_map_t mp_const_empty_map;
 
-static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) { return ((map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL); }
+static inline bool mp_map_slot_is_filled(const mp_map_t *map, size_t pos) {
+    return (map)->table[pos].key != MP_OBJ_NULL && (map)->table[pos].key != MP_OBJ_SENTINEL;
+}
 
 void mp_map_init(mp_map_t *map, size_t n);
 void mp_map_init_fixed_table(mp_map_t *map, size_t n, const mp_obj_t *table);
@@ -421,7 +443,9 @@
     mp_obj_t *table;
 } mp_set_t;
 
-static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) { return ((set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL); }
+static inline bool mp_set_slot_is_filled(const mp_set_t *set, size_t pos) {
+    return (set)->table[pos] != MP_OBJ_NULL && (set)->table[pos] != MP_OBJ_SENTINEL;
+}
 
 void mp_set_init(mp_set_t *set, size_t n);
 mp_obj_t mp_set_lookup(mp_set_t *set, mp_obj_t index, mp_map_lookup_kind_t lookup_kind);
@@ -672,7 +696,7 @@
 // check for more specific object types.
 // Note: these are kept as macros because inline functions sometimes use much
 // more code space than the equivalent macros, depending on the compiler.
-#define mp_obj_is_type(o, t) (mp_obj_is_obj(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type == (t))) // this does not work for checking int, str or fun; use below macros for that
+#define mp_obj_is_type(o, t) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type == (t))) // this does not work for checking int, str or fun; use below macros for that
 #if MICROPY_OBJ_IMMEDIATE_OBJS
 // bool's are immediates, not real objects, so test for the 2 possible values.
 #define mp_obj_is_bool(o) ((o) == mp_const_false || (o) == mp_const_true)
@@ -681,21 +705,23 @@
 #endif
 #define mp_obj_is_int(o) (mp_obj_is_small_int(o) || mp_obj_is_type(o, &mp_type_int))
 #define mp_obj_is_str(o) (mp_obj_is_qstr(o) || mp_obj_is_type(o, &mp_type_str))
-#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->binary_op == mp_obj_str_binary_op))
-#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))
+#define mp_obj_is_str_or_bytes(o) (mp_obj_is_qstr(o) || (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->binary_op == mp_obj_str_binary_op))
+#define mp_obj_is_fun(o) (mp_obj_is_obj(o) && (((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->name == MP_QSTR_function))
 
 mp_obj_t mp_obj_new_type(qstr name, mp_obj_t bases_tuple, mp_obj_t locals_dict);
-static inline mp_obj_t mp_obj_new_bool(mp_int_t x) { return x ? mp_const_true : mp_const_false; }
+static inline mp_obj_t mp_obj_new_bool(mp_int_t x) {
+    return x ? mp_const_true : mp_const_false;
+}
 mp_obj_t mp_obj_new_cell(mp_obj_t obj);
 mp_obj_t mp_obj_new_int(mp_int_t value);
 mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value);
 mp_obj_t mp_obj_new_int_from_str_len(const char **str, size_t len, bool neg, unsigned int base);
 mp_obj_t mp_obj_new_int_from_ll(long long val); // this must return a multi-precision integer object (or raise an overflow exception)
 mp_obj_t mp_obj_new_int_from_ull(unsigned long long val); // this must return a multi-precision integer object (or raise an overflow exception)
-mp_obj_t mp_obj_new_str(const char* data, size_t len);
-mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len);
+mp_obj_t mp_obj_new_str(const char *data, size_t len);
+mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len);
 mp_obj_t mp_obj_new_str_from_vstr(const mp_obj_type_t *type, vstr_t *vstr);
-mp_obj_t mp_obj_new_bytes(const byte* data, size_t len);
+mp_obj_t mp_obj_new_bytes(const byte *data, size_t len);
 mp_obj_t mp_obj_new_bytearray(size_t n, void *items);
 mp_obj_t mp_obj_new_bytearray_by_ref(size_t n, void *items);
 #if MICROPY_PY_BUILTINS_FLOAT
@@ -739,7 +765,9 @@
 mp_obj_t mp_obj_equal_not_equal(mp_binary_op_t op, mp_obj_t o1, mp_obj_t o2);
 bool mp_obj_equal(mp_obj_t o1, mp_obj_t o2);
 
-static inline bool mp_obj_is_integer(mp_const_obj_t o) { return mp_obj_is_int(o) || mp_obj_is_bool(o); } // returns true if o is bool, small int or long int
+static inline bool mp_obj_is_integer(mp_const_obj_t o) {
+    return mp_obj_is_int(o) || mp_obj_is_bool(o);
+}                                                                                                        // returns true if o is bool, small int or long int
 mp_int_t mp_obj_get_int(mp_const_obj_t arg);
 mp_int_t mp_obj_get_int_truncated(mp_const_obj_t arg);
 bool mp_obj_get_int_maybe(mp_const_obj_t arg, mp_int_t *value);
@@ -796,7 +824,9 @@
 #if MICROPY_FLOAT_HIGH_QUALITY_HASH
 mp_int_t mp_float_hash(mp_float_t val);
 #else
-static inline mp_int_t mp_float_hash(mp_float_t val) { return (mp_int_t)val; }
+static inline mp_int_t mp_float_hash(mp_float_t val) {
+    return (mp_int_t)val;
+}
 #endif
 mp_obj_t mp_obj_float_binary_op(mp_binary_op_t op, mp_float_t lhs_val, mp_obj_t rhs); // can return MP_OBJ_NULL if op not supported
 
@@ -831,7 +861,7 @@
 mp_obj_t mp_obj_dict_store(mp_obj_t self_in, mp_obj_t key, mp_obj_t value);
 mp_obj_t mp_obj_dict_delete(mp_obj_t self_in, mp_obj_t key);
 static inline mp_map_t *mp_obj_dict_get_map(mp_obj_t dict) {
-    return &((mp_obj_dict_t*)MP_OBJ_TO_PTR(dict))->map;
+    return &((mp_obj_dict_t *)MP_OBJ_TO_PTR(dict))->map;
 }
 
 // set
@@ -887,7 +917,7 @@
     mp_obj_dict_t *globals;
 } mp_obj_module_t;
 static inline mp_obj_dict_t *mp_obj_module_get_globals(mp_obj_t module) {
-    return ((mp_obj_module_t*)MP_OBJ_TO_PTR(module))->globals;
+    return ((mp_obj_module_t *)MP_OBJ_TO_PTR(module))->globals;
 }
 // check if given module object is a package
 bool mp_obj_is_package(mp_obj_t module);
@@ -920,18 +950,18 @@
 mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value);
 mp_obj_t mp_seq_extract_slice(size_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes);
 // Helper to clear stale pointers from allocated, but unused memory, to preclude GC problems
-#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte*)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))
+#define mp_seq_clear(start, len, alloc_len, item_sz) memset((byte *)(start) + (len) * (item_sz), 0, ((alloc_len) - (len)) * (item_sz))
 #define mp_seq_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_sz) \
     /*printf("memcpy(%p, %p, %d)\n", dest + beg, slice, slice_len * (item_sz));*/ \
-    memcpy(((char*)dest) + (beg) * (item_sz), slice, slice_len * (item_sz)); \
+    memcpy(((char *)dest) + (beg) * (item_sz), slice, slice_len * (item_sz)); \
     /*printf("memmove(%p, %p, %d)\n", dest + (beg + slice_len), dest + end, (dest_len - end) * (item_sz));*/ \
-    memmove(((char*)dest) + (beg + slice_len) * (item_sz), ((char*)dest) + (end) * (item_sz), (dest_len - end) * (item_sz));
+    memmove(((char *)dest) + (beg + slice_len) * (item_sz), ((char *)dest) + (end) * (item_sz), (dest_len - end) * (item_sz));
 
 // Note: dest and slice regions may overlap
 #define mp_seq_replace_slice_grow_inplace(dest, dest_len, beg, end, slice, slice_len, len_adj, item_sz) \
     /*printf("memmove(%p, %p, %d)\n", dest + beg + len_adj, dest + beg, (dest_len - beg) * (item_sz));*/ \
-    memmove(((char*)dest) + (beg + slice_len) * (item_sz), ((char*)dest) + (end) * (item_sz), ((dest_len) + (len_adj) - ((beg) + (slice_len))) * (item_sz)); \
-    memmove(((char*)dest) + (beg) * (item_sz), slice, slice_len * (item_sz));
+    memmove(((char *)dest) + (beg + slice_len) * (item_sz), ((char *)dest) + (end) * (item_sz), ((dest_len) + (len_adj) - ((beg) + (slice_len))) * (item_sz)); \
+    memmove(((char *)dest) + (beg) * (item_sz), slice, slice_len * (item_sz));
 
 // Provide translation for legacy API
 #define MP_OBJ_IS_SMALL_INT mp_obj_is_small_int
diff --git a/py/objarray.c b/py/objarray.c
index 760eff8..7f5cbf0 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -117,10 +117,10 @@
     // other arrays can only be raw-initialised from bytes and bytearray objects
     mp_buffer_info_t bufinfo;
     if (((MICROPY_PY_BUILTINS_BYTEARRAY
-            && typecode == BYTEARRAY_TYPECODE)
-        || (MICROPY_PY_ARRAY
-            && (mp_obj_is_type(initializer, &mp_type_bytes)
-                || (MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(initializer, &mp_type_bytearray)))))
+          && typecode == BYTEARRAY_TYPECODE)
+         || (MICROPY_PY_ARRAY
+             && (mp_obj_is_type(initializer, &mp_type_bytes)
+                 || (MICROPY_PY_BUILTINS_BYTEARRAY && mp_obj_is_type(initializer, &mp_type_bytearray)))))
         && mp_get_buffer(initializer, &bufinfo, MP_BUFFER_READ)) {
         // construct array from raw bytes
         // we round-down the len to make it a multiple of sz (CPython raises error)
@@ -249,9 +249,12 @@
 STATIC mp_obj_t array_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_array_t *o = MP_OBJ_TO_PTR(o_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->len != 0);
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(o->len);
-        default: return MP_OBJ_NULL; // op not supported
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(o->len != 0);
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(o->len);
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -272,7 +275,7 @@
 
             // note: lhs->len is element count of lhs, lhs_bufinfo.len is byte count
             mp_obj_array_t *res = array_new(lhs_bufinfo.typecode, lhs->len + rhs_len);
-            mp_seq_cat((byte*)res->items, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_len * sz, byte);
+            mp_seq_cat((byte *)res->items, lhs_bufinfo.buf, lhs_bufinfo.len, rhs_bufinfo.buf, rhs_len * sz, byte);
             return MP_OBJ_FROM_PTR(res);
         }
 
@@ -371,7 +374,7 @@
     }
 
     // extend
-    mp_seq_copy((byte*)self->items + self->len * sz, arg_bufinfo.buf, len * sz, byte);
+    mp_seq_copy((byte *)self->items + self->len * sz, arg_bufinfo.buf, len * sz, byte);
     self->len += len;
 
     return mp_const_none;
@@ -388,7 +391,7 @@
         return MP_OBJ_NULL; // op not supported
     } else {
         mp_obj_array_t *o = MP_OBJ_TO_PTR(self_in);
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index_in, &mp_type_slice)) {
             mp_bound_slice_t slice;
             if (!mp_seq_get_fast_slice_indexes(o->len, index_in, &slice)) {
@@ -400,7 +403,7 @@
                 size_t src_len;
                 void *src_items;
                 size_t item_sz = mp_binary_get_size('@', o->typecode & TYPECODE_MASK, NULL);
-                if (mp_obj_is_obj(value) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(value))->type->subscr == array_subscr) {
+                if (mp_obj_is_obj(value) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(value))->type->subscr == array_subscr) {
                     // value is array, bytearray or memoryview
                     mp_obj_array_t *src_slice = MP_OBJ_TO_PTR(value);
                     if (item_sz != mp_binary_get_size('@', src_slice->typecode & TYPECODE_MASK, NULL)) {
@@ -411,7 +414,7 @@
                     src_items = src_slice->items;
                     #if MICROPY_PY_BUILTINS_MEMORYVIEW
                     if (mp_obj_is_type(value, &mp_type_memoryview)) {
-                        src_items = (uint8_t*)src_items + (src_slice->memview_offset * item_sz);
+                        src_items = (uint8_t *)src_items + (src_slice->memview_offset * item_sz);
                     }
                     #endif
                 } else if (mp_obj_is_type(value, &mp_type_bytes)) {
@@ -428,7 +431,7 @@
 
                 // TODO: check src/dst compat
                 mp_int_t len_adj = src_len - (slice.stop - slice.start);
-                uint8_t* dest_items = o->items;
+                uint8_t *dest_items = o->items;
                 #if MICROPY_PY_BUILTINS_MEMORYVIEW
                 if (o->base.type == &mp_type_memoryview) {
                     if (!(o->typecode & MP_OBJ_ARRAY_TYPECODE_FLAG_RW)) {
@@ -479,11 +482,11 @@
             #endif
             {
                 res = array_new(o->typecode, slice.stop - slice.start);
-                memcpy(res->items, (uint8_t*)o->items + slice.start * sz, (slice.stop - slice.start) * sz);
+                memcpy(res->items, (uint8_t *)o->items + slice.start * sz, (slice.stop - slice.start) * sz);
             }
             return MP_OBJ_FROM_PTR(res);
         } else
-#endif
+        #endif
         {
             size_t index = mp_get_index(o->base.type, o->len, index_in, false);
             #if MICROPY_PY_BUILTINS_MEMORYVIEW
@@ -519,7 +522,7 @@
             // read-only memoryview
             return 1;
         }
-        bufinfo->buf = (uint8_t*)bufinfo->buf + (size_t)o->memview_offset * sz;
+        bufinfo->buf = (uint8_t *)bufinfo->buf + (size_t)o->memview_offset * sz;
     }
     #else
     (void)flags;
@@ -550,7 +553,7 @@
     .binary_op = array_binary_op,
     .subscr = array_subscr,
     .buffer_p = { .get_buffer = array_get_buffer },
-    .locals_dict = (mp_obj_dict_t*)&array_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&array_locals_dict,
 };
 #endif
 
@@ -566,7 +569,7 @@
     .binary_op = array_binary_op,
     .subscr = array_subscr,
     .buffer_p = { .get_buffer = array_get_buffer },
-    .locals_dict = (mp_obj_dict_t*)&array_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&array_locals_dict,
 };
 #endif
 
@@ -641,7 +644,7 @@
 STATIC mp_obj_t array_iterator_new(mp_obj_t array_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_array_t) <= sizeof(mp_obj_iter_buf_t));
     mp_obj_array_t *array = MP_OBJ_TO_PTR(array_in);
-    mp_obj_array_it_t *o = (mp_obj_array_it_t*)iter_buf;
+    mp_obj_array_it_t *o = (mp_obj_array_it_t *)iter_buf;
     o->base.type = &array_it_type;
     o->array = array;
     o->offset = 0;
diff --git a/py/objattrtuple.c b/py/objattrtuple.c
index 3cc298d..3422d01 100644
--- a/py/objattrtuple.c
+++ b/py/objattrtuple.c
@@ -51,7 +51,7 @@
 STATIC void mp_obj_attrtuple_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_tuple_t *o = MP_OBJ_TO_PTR(o_in);
-    const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(o->items[o->len]);
+    const qstr *fields = (const qstr *)MP_OBJ_TO_PTR(o->items[o->len]);
     mp_obj_attrtuple_print_helper(print, fields, o);
 }
 
@@ -60,7 +60,7 @@
         // load attribute
         mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
         size_t len = self->len;
-        const qstr *fields = (const qstr*)MP_OBJ_TO_PTR(self->items[len]);
+        const qstr *fields = (const qstr *)MP_OBJ_TO_PTR(self->items[len]);
         for (size_t i = 0; i < len; i++) {
             if (fields[i] == attr) {
                 dest[0] = self->items[i];
diff --git a/py/objbool.c b/py/objbool.c
index 1183a7e..23e023d 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -34,7 +34,7 @@
 
 #else
 
-#define BOOL_VALUE(o) (((mp_obj_bool_t*)MP_OBJ_TO_PTR(o))->value)
+#define BOOL_VALUE(o) (((mp_obj_bool_t *)MP_OBJ_TO_PTR(o))->value)
 
 typedef struct _mp_obj_bool_t {
     mp_obj_base_t base;
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index 8fc44f1..a3e1d30 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -98,13 +98,13 @@
 STATIC const mp_obj_type_t mp_type_bound_meth = {
     { &mp_type_type },
     .name = MP_QSTR_bound_method,
-#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
+    #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
     .print = bound_meth_print,
-#endif
+    #endif
     .call = bound_meth_call,
-#if MICROPY_PY_FUNCTION_ATTRS
+    #if MICROPY_PY_FUNCTION_ATTRS
     .attr = bound_meth_attr,
-#endif
+    #endif
 };
 
 mp_obj_t mp_obj_new_bound_meth(mp_obj_t meth, mp_obj_t self) {
diff --git a/py/objcell.c b/py/objcell.c
index 1119064..be2ae8c 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -58,9 +58,9 @@
 STATIC const mp_obj_type_t mp_type_cell = {
     { &mp_type_type },
     .name = MP_QSTR_, // cell representation is just value in < >
-#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
+    #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
     .print = cell_print,
-#endif
+    #endif
 };
 
 mp_obj_t mp_obj_new_cell(mp_obj_t obj) {
diff --git a/py/objclosure.c b/py/objclosure.c
index 4eb9eb8..f5038ff 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -81,9 +81,9 @@
 const mp_obj_type_t closure_type = {
     { &mp_type_type },
     .name = MP_QSTR_closure,
-#if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
+    #if MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_DETAILED
     .print = closure_print,
-#endif
+    #endif
     .call = closure_call,
 };
 
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 2031c1c..b7af1b1 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -45,17 +45,17 @@
 STATIC void complex_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
+    #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
     char buf[16];
     #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
     const int precision = 6;
     #else
     const int precision = 7;
     #endif
-#else
+    #else
     char buf[32];
     const int precision = 16;
-#endif
+    #endif
     if (o->real == 0) {
         mp_format_float(o->imag, buf, sizeof(buf), 'g', precision, '\0');
         mp_printf(print, "%sj", buf);
@@ -117,13 +117,18 @@
 STATIC mp_obj_t complex_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_complex_t *o = MP_OBJ_TO_PTR(o_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->real != 0 || o->imag != 0);
-        case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(o->real) ^ mp_float_hash(o->imag));
-        case MP_UNARY_OP_POSITIVE: return o_in;
-        case MP_UNARY_OP_NEGATIVE: return mp_obj_new_complex(-o->real, -o->imag);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(o->real != 0 || o->imag != 0);
+        case MP_UNARY_OP_HASH:
+            return MP_OBJ_NEW_SMALL_INT(mp_float_hash(o->real) ^ mp_float_hash(o->imag));
+        case MP_UNARY_OP_POSITIVE:
+            return o_in;
+        case MP_UNARY_OP_NEGATIVE:
+            return mp_obj_new_complex(-o->real, -o->imag);
         case MP_UNARY_OP_ABS:
-            return mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(o->real*o->real + o->imag*o->imag));
-        default: return MP_OBJ_NULL; // op not supported
+            return mp_obj_new_float(MICROPY_FLOAT_C_FUN(sqrt)(o->real * o->real + o->imag * o->imag));
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -188,7 +193,7 @@
         case MP_BINARY_OP_MULTIPLY:
         case MP_BINARY_OP_INPLACE_MULTIPLY: {
             mp_float_t real;
-            multiply:
+        multiply:
             real = lhs_real * rhs_real - lhs_imag * rhs_imag;
             lhs_imag = lhs_real * rhs_imag + lhs_imag * rhs_real;
             lhs_real = real;
@@ -211,7 +216,7 @@
                 lhs_imag = -lhs_real / rhs_imag;
                 lhs_real = real;
             } else {
-                mp_float_t rhs_len_sq = rhs_real*rhs_real + rhs_imag*rhs_imag;
+                mp_float_t rhs_len_sq = rhs_real * rhs_real + rhs_imag * rhs_imag;
                 rhs_real /= rhs_len_sq;
                 rhs_imag /= -rhs_len_sq;
                 goto multiply;
@@ -225,7 +230,7 @@
             //        = exp( (x2*ln1 - y2*arg1) + i*(y2*ln1 + x2*arg1) )
             //        = exp(x3 + i*y3)
             //        = exp(x3)*(cos(y3) + i*sin(y3))
-            mp_float_t abs1 = MICROPY_FLOAT_C_FUN(sqrt)(lhs_real*lhs_real + lhs_imag*lhs_imag);
+            mp_float_t abs1 = MICROPY_FLOAT_C_FUN(sqrt)(lhs_real * lhs_real + lhs_imag * lhs_imag);
             if (abs1 == 0) {
                 if (rhs_imag == 0 && rhs_real >= 0) {
                     lhs_real = (rhs_real == 0);
@@ -244,7 +249,8 @@
             break;
         }
 
-        case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_real == rhs_real && lhs_imag == rhs_imag);
+        case MP_BINARY_OP_EQUAL:
+            return mp_obj_new_bool(lhs_real == rhs_real && lhs_imag == rhs_imag);
 
         default:
             return MP_OBJ_NULL; // op not supported
diff --git a/py/objdeque.c b/py/objdeque.c
index 1cff1f8..0eb6665 100644
--- a/py/objdeque.c
+++ b/py/objdeque.c
@@ -161,7 +161,7 @@
     .name = MP_QSTR_deque,
     .make_new = deque_make_new,
     .unary_op = deque_unary_op,
-    .locals_dict = (mp_obj_dict_t*)&deque_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&deque_locals_dict,
 };
 
 #endif // MICROPY_PY_COLLECTIONS_DEQUE
diff --git a/py/objdict.c b/py/objdict.c
index f831a04..5447826 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -33,7 +33,7 @@
 #include "py/objtype.h"
 #include "py/objstr.h"
 
-#define mp_obj_is_dict_type(o) (mp_obj_is_obj(o) && ((mp_obj_base_t*)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new)
+#define mp_obj_is_dict_type(o) (mp_obj_is_obj(o) && ((mp_obj_base_t *)MP_OBJ_TO_PTR(o))->type->make_new == dict_make_new)
 
 STATIC mp_obj_t dict_update(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
 
@@ -109,15 +109,18 @@
 STATIC mp_obj_t dict_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_dict_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->map.used != 0);
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->map.used);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(self->map.used != 0);
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(self->map.used);
         #if MICROPY_PY_SYS_GETSIZEOF
         case MP_UNARY_OP_SIZEOF: {
             size_t sz = sizeof(*self) + sizeof(*self->map.table) * self->map.alloc;
             return MP_OBJ_NEW_SMALL_INT(sz);
         }
         #endif
-        default: return MP_OBJ_NULL; // op not supported
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -348,7 +351,7 @@
             if (args[1] != args[0]) {
                 size_t cur = 0;
                 mp_map_elem_t *elem = NULL;
-                while ((elem = dict_iter_next((mp_obj_dict_t*)MP_OBJ_TO_PTR(args[1]), &cur)) != NULL) {
+                while ((elem = dict_iter_next((mp_obj_dict_t *)MP_OBJ_TO_PTR(args[1]), &cur)) != NULL) {
                     mp_map_lookup(&self->map, elem->key, MP_MAP_LOOKUP_ADD_IF_NOT_FOUND)->value = elem->value;
                 }
             }
@@ -444,7 +447,7 @@
     assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_check_self(mp_obj_is_type(view_in, &dict_view_type));
     mp_obj_dict_view_t *view = MP_OBJ_TO_PTR(view_in);
-    mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf;
+    mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t *)iter_buf;
     o->base.type = &dict_view_it_type;
     o->kind = view->kind;
     o->dict = view->dict;
@@ -526,7 +529,7 @@
 STATIC mp_obj_t dict_getiter(mp_obj_t self_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_dict_view_it_t) <= sizeof(mp_obj_iter_buf_t));
     mp_check_self(mp_obj_is_dict_type(self_in));
-    mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t*)iter_buf;
+    mp_obj_dict_view_it_t *o = (mp_obj_dict_view_it_t *)iter_buf;
     o->base.type = &dict_view_it_type;
     o->kind = MP_DICT_VIEW_KEYS;
     o->dict = self_in;
@@ -567,7 +570,7 @@
     .binary_op = dict_binary_op,
     .subscr = dict_subscr,
     .getiter = dict_getiter,
-    .locals_dict = (mp_obj_dict_t*)&dict_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&dict_locals_dict,
 };
 
 #if MICROPY_PY_COLLECTIONS_ORDEREDDICT
@@ -581,7 +584,7 @@
     .subscr = dict_subscr,
     .getiter = dict_getiter,
     .parent = &mp_type_dict,
-    .locals_dict = (mp_obj_dict_t*)&dict_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&dict_locals_dict,
 };
 #endif
 
diff --git a/py/objenumerate.c b/py/objenumerate.c
index 243c9f8..d1de4ad 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -40,7 +40,7 @@
 STATIC mp_obj_t enumerate_iternext(mp_obj_t self_in);
 
 STATIC mp_obj_t enumerate_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     static const mp_arg_t allowed_args[] = {
         { MP_QSTR_iterable, MP_ARG_REQUIRED | MP_ARG_OBJ, {.u_obj = MP_OBJ_NULL} },
         { MP_QSTR_start, MP_ARG_INT, {.u_int = 0} },
@@ -51,20 +51,20 @@
         mp_arg_val_t iterable, start;
     } arg_vals;
     mp_arg_parse_all_kw_array(n_args, n_kw, args,
-        MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&arg_vals);
+        MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t *)&arg_vals);
 
     // create enumerate object
     mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
     o->base.type = type;
     o->iter = mp_getiter(arg_vals.iterable.u_obj, NULL);
     o->cur = arg_vals.start.u_int;
-#else
+    #else
     mp_arg_check_num(n_args, n_kw, 1, 2, false);
     mp_obj_enumerate_t *o = m_new_obj(mp_obj_enumerate_t);
     o->base.type = type;
     o->iter = mp_getiter(args[0], NULL);
     o->cur = n_args > 1 ? mp_obj_get_int(args[1]) : 0;
-#endif
+    #endif
 
     return MP_OBJ_FROM_PTR(o);
 }
diff --git a/py/objexcept.c b/py/objexcept.c
index b5c1693..ef99019 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -58,7 +58,7 @@
 #define EMG_BUF_TUPLE_SIZE(n_args)  (sizeof(mp_obj_tuple_t) + n_args * sizeof(mp_obj_t))
 #define EMG_BUF_STR_OFFSET          (EMG_BUF_TUPLE_OFFSET + EMG_BUF_TUPLE_SIZE(1))
 
-#   if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0
+#if MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE > 0
 #define mp_emergency_exception_buf_size MICROPY_EMERGENCY_EXCEPTION_BUF_SIZE
 
 void mp_init_emergency_exception_buf(void) {
@@ -150,7 +150,7 @@
     mp_obj_tuple_t *o_tuple;
     if (n_args == 0) {
         // No args, can use the empty tuple straightaway
-        o_tuple = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
+        o_tuple = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
     } else {
         // Try to allocate memory for the tuple containing the args
         o_tuple = m_new_obj_var_maybe(mp_obj_tuple_t, mp_obj_t, n_args);
@@ -161,14 +161,14 @@
         // Otherwise we are free to use the whole buffer after the traceback data.
         if (o_tuple == NULL && mp_emergency_exception_buf_size >=
             EMG_BUF_TUPLE_OFFSET + EMG_BUF_TUPLE_SIZE(n_args)) {
-            o_tuple = (mp_obj_tuple_t*)
-                ((uint8_t*)MP_STATE_VM(mp_emergency_exception_buf) + EMG_BUF_TUPLE_OFFSET);
+            o_tuple = (mp_obj_tuple_t *)
+                ((uint8_t *)MP_STATE_VM(mp_emergency_exception_buf) + EMG_BUF_TUPLE_OFFSET);
         }
         #endif
 
         if (o_tuple == NULL) {
             // No memory for a tuple, fallback to an empty tuple
-            o_tuple = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
+            o_tuple = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
         } else {
             // Have memory for a tuple so populate it
             o_tuple->base.type = &mp_type_tuple;
@@ -336,7 +336,7 @@
     // traceback and 1-tuple.
     if (o_str == NULL
         && mp_emergency_exception_buf_size >= EMG_BUF_STR_OFFSET + sizeof(mp_obj_str_t)) {
-        o_str = (mp_obj_str_t*)((uint8_t*)MP_STATE_VM(mp_emergency_exception_buf)
+        o_str = (mp_obj_str_t *)((uint8_t *)MP_STATE_VM(mp_emergency_exception_buf)
             + EMG_BUF_STR_OFFSET);
     }
     #endif
@@ -349,7 +349,7 @@
     // Create the string object and call mp_obj_exception_make_new to create the exception
     o_str->base.type = &mp_type_str;
     o_str->len = strlen(msg);
-    o_str->data = (const byte*)msg;
+    o_str->data = (const byte *)msg;
     o_str->hash = qstr_compute_hash(o_str->data, o_str->len);
     mp_obj_t arg = MP_OBJ_FROM_PTR(o_str);
     return mp_obj_exception_make_new(exc_type, 1, 0, &arg);
@@ -415,10 +415,10 @@
     if ((o_str == NULL || o_str_buf == NULL)
         && mp_emergency_exception_buf_size >= EMG_BUF_STR_OFFSET + sizeof(mp_obj_str_t) + 16) {
         used_emg_buf = true;
-        o_str = (mp_obj_str_t*)((uint8_t*)MP_STATE_VM(mp_emergency_exception_buf)
+        o_str = (mp_obj_str_t *)((uint8_t *)MP_STATE_VM(mp_emergency_exception_buf)
             + EMG_BUF_STR_OFFSET);
-        o_str_buf = (byte*)&o_str[1];
-        o_str_alloc = (uint8_t*)MP_STATE_VM(mp_emergency_exception_buf)
+        o_str_buf = (byte *)&o_str[1];
+        o_str_alloc = (uint8_t *)MP_STATE_VM(mp_emergency_exception_buf)
             + mp_emergency_exception_buf_size - o_str_buf;
     }
     #endif
@@ -432,7 +432,7 @@
         // No memory for the string buffer: assume that the fmt string is in ROM
         // and use that data as the data of the string
         o_str->len = o_str_alloc - 1; // will be equal to strlen(fmt)
-        o_str->data = (const byte*)fmt;
+        o_str->data = (const byte *)fmt;
     } else {
         // We have some memory to format the string
         struct _exc_printer_t exc_pr = {!used_emg_buf, o_str_alloc, 0, o_str_buf};
@@ -487,7 +487,7 @@
     if (mp_obj_is_native_exception_instance(self_in)) { \
         self = MP_OBJ_TO_PTR(self_in); \
     } else { \
-        self = MP_OBJ_TO_PTR(((mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in))->subobj[0]); \
+        self = MP_OBJ_TO_PTR(((mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in))->subobj[0]); \
     }
 
 void mp_obj_exception_clear_traceback(mp_obj_t self_in) {
@@ -509,7 +509,7 @@
             #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
             if (mp_emergency_exception_buf_size >= EMG_BUF_TRACEBACK_OFFSET + EMG_BUF_TRACEBACK_SIZE) {
                 // There is room in the emergency buffer for traceback data
-                size_t *tb = (size_t*)((uint8_t*)MP_STATE_VM(mp_emergency_exception_buf)
+                size_t *tb = (size_t *)((uint8_t *)MP_STATE_VM(mp_emergency_exception_buf)
                     + EMG_BUF_TRACEBACK_OFFSET);
                 self->traceback_data = tb;
                 self->traceback_alloc = EMG_BUF_TRACEBACK_SIZE / sizeof(size_t);
@@ -528,7 +528,7 @@
         self->traceback_len = 0;
     } else if (self->traceback_len + TRACEBACK_ENTRY_LEN > self->traceback_alloc) {
         #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
-        if (self->traceback_data == (size_t*)MP_STATE_VM(mp_emergency_exception_buf)) {
+        if (self->traceback_data == (size_t *)MP_STATE_VM(mp_emergency_exception_buf)) {
             // Can't resize the emergency buffer
             return;
         }
diff --git a/py/objexcept.h b/py/objexcept.h
index 7c30762..384456b 100644
--- a/py/objexcept.h
+++ b/py/objexcept.h
@@ -41,13 +41,13 @@
 void mp_obj_exception_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest);
 
 #define MP_DEFINE_EXCEPTION(exc_name, base_name) \
-const mp_obj_type_t mp_type_ ## exc_name = { \
-    { &mp_type_type }, \
-    .name = MP_QSTR_ ## exc_name, \
-    .print = mp_obj_exception_print, \
-    .make_new = mp_obj_exception_make_new, \
-    .attr = mp_obj_exception_attr, \
-    .parent = &mp_type_ ## base_name, \
-};
+    const mp_obj_type_t mp_type_##exc_name = { \
+        { &mp_type_type }, \
+        .name = MP_QSTR_##exc_name, \
+        .print = mp_obj_exception_print, \
+        .make_new = mp_obj_exception_make_new, \
+        .attr = mp_obj_exception_attr, \
+        .parent = &mp_type_##base_name, \
+    };
 
 #endif // MICROPY_INCLUDED_PY_OBJEXCEPT_H
diff --git a/py/objfloat.c b/py/objfloat.c
index 0554307..40619d7 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -95,17 +95,17 @@
 STATIC void float_print(const mp_print_t *print, mp_obj_t o_in, mp_print_kind_t kind) {
     (void)kind;
     mp_float_t o_val = mp_obj_float_get(o_in);
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
+    #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
     char buf[16];
     #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C
     const int precision = 6;
     #else
     const int precision = 7;
     #endif
-#else
+    #else
     char buf[32];
     const int precision = 16;
-#endif
+    #endif
     mp_format_float(o_val, buf, sizeof(buf), 'g', precision, '\0');
     mp_print_str(print, buf);
     if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL && strchr(buf, 'n') == NULL) {
@@ -142,10 +142,14 @@
 STATIC mp_obj_t float_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_float_t val = mp_obj_float_get(o_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(val != 0);
-        case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mp_float_hash(val));
-        case MP_UNARY_OP_POSITIVE: return o_in;
-        case MP_UNARY_OP_NEGATIVE: return mp_obj_new_float(-val);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(val != 0);
+        case MP_UNARY_OP_HASH:
+            return MP_OBJ_NEW_SMALL_INT(mp_float_hash(val));
+        case MP_UNARY_OP_POSITIVE:
+            return o_in;
+        case MP_UNARY_OP_NEGATIVE:
+            return mp_obj_new_float(-val);
         case MP_UNARY_OP_ABS: {
             if (signbit(val)) {
                 return mp_obj_new_float(-val);
@@ -153,7 +157,8 @@
                 return o_in;
             }
         }
-        default: return MP_OBJ_NULL; // op not supported
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -237,15 +242,21 @@
 
     switch (op) {
         case MP_BINARY_OP_ADD:
-        case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break;
+        case MP_BINARY_OP_INPLACE_ADD:
+            lhs_val += rhs_val;
+            break;
         case MP_BINARY_OP_SUBTRACT:
-        case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break;
+        case MP_BINARY_OP_INPLACE_SUBTRACT:
+            lhs_val -= rhs_val;
+            break;
         case MP_BINARY_OP_MULTIPLY:
-        case MP_BINARY_OP_INPLACE_MULTIPLY: lhs_val *= rhs_val; break;
+        case MP_BINARY_OP_INPLACE_MULTIPLY:
+            lhs_val *= rhs_val;
+            break;
         case MP_BINARY_OP_FLOOR_DIVIDE:
         case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE:
             if (rhs_val == 0) {
-                zero_division_error:
+            zero_division_error:
                 mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
             }
             // Python specs require that x == (x//y)*y + (x%y) so we must
@@ -300,11 +311,16 @@
             };
             return mp_obj_new_tuple(2, tuple);
         }
-        case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val);
-        case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val);
-        case MP_BINARY_OP_EQUAL: return mp_obj_new_bool(lhs_val == rhs_val);
-        case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val);
-        case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val);
+        case MP_BINARY_OP_LESS:
+            return mp_obj_new_bool(lhs_val < rhs_val);
+        case MP_BINARY_OP_MORE:
+            return mp_obj_new_bool(lhs_val > rhs_val);
+        case MP_BINARY_OP_EQUAL:
+            return mp_obj_new_bool(lhs_val == rhs_val);
+        case MP_BINARY_OP_LESS_EQUAL:
+            return mp_obj_new_bool(lhs_val <= rhs_val);
+        case MP_BINARY_OP_MORE_EQUAL:
+            return mp_obj_new_bool(lhs_val >= rhs_val);
 
         default:
             return MP_OBJ_NULL; // op not supported
diff --git a/py/objfun.c b/py/objfun.c
index dbff2fa..1afb0f8 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -197,8 +197,8 @@
         MP_BC_PRELUDE_SIG_DECODE_INTO(ip, n_state_out_var, n_exc_stack, scope_flags, n_pos_args, n_kwonly_args, n_def_args); \
                                     \
         /* state size in bytes */                                                 \
-        state_size_out_var = n_state_out_var * sizeof(mp_obj_t)                   \
-                           + n_exc_stack * sizeof(mp_exc_stack_t);                \
+        state_size_out_var = n_state_out_var *sizeof(mp_obj_t)                   \
+            + n_exc_stack *sizeof(mp_exc_stack_t);                \
     }
 
 #define INIT_CODESTATE(code_state, _fun_bc, _n_state, n_args, n_kw, args) \
@@ -356,14 +356,14 @@
 const mp_obj_type_t mp_type_fun_bc = {
     { &mp_type_type },
     .name = MP_QSTR_function,
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     .print = fun_bc_print,
-#endif
+    #endif
     .call = fun_bc_call,
     .unary_op = mp_generic_unary_op,
-#if MICROPY_PY_FUNCTION_ATTRS
+    #if MICROPY_PY_FUNCTION_ATTRS
     .attr = mp_obj_fun_bc_attr,
-#endif
+    #endif
 };
 
 mp_obj_t mp_obj_new_fun_bc(mp_obj_t def_args_in, mp_obj_t def_kw_args, const byte *code, const mp_uint_t *const_table) {
@@ -400,7 +400,7 @@
 STATIC mp_obj_t fun_native_call(mp_obj_t self_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
     MP_STACK_CHECK();
     mp_obj_fun_bc_t *self = self_in;
-    mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void*)self->bytecode);
+    mp_call_fun_t fun = MICROPY_MAKE_POINTER_CALLABLE((void *)self->bytecode);
     return fun(self_in, n_args, n_kw, args);
 }
 
@@ -412,7 +412,7 @@
 };
 
 mp_obj_t mp_obj_new_fun_native(mp_obj_t def_args_in, mp_obj_t def_kw_args, const void *fun_data, const mp_uint_t *const_table) {
-    mp_obj_fun_bc_t *o = mp_obj_new_fun_bc(def_args_in, def_kw_args, (const byte*)fun_data, const_table);
+    mp_obj_fun_bc_t *o = mp_obj_new_fun_bc(def_args_in, def_kw_args, (const byte *)fun_data, const_table);
     o->base.type = &mp_type_fun_native;
     return o;
 }
@@ -505,7 +505,7 @@
             convert_obj_for_inline_asm(args[1]),
             convert_obj_for_inline_asm(args[2]),
             convert_obj_for_inline_asm(args[3])
-        );
+            );
     }
 
     return mp_native_to_obj(ret, self->type_sig);
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 2bb96bc..cd88e96 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -36,7 +36,7 @@
 #include "py/stackctrl.h"
 
 // Instance of GeneratorExit exception - needed by generator.close()
-const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t*)&mp_const_empty_tuple_obj};
+const mp_obj_exception_t mp_const_GeneratorExit_obj = {{&mp_type_GeneratorExit}, 0, 0, NULL, (mp_obj_tuple_t *)&mp_const_empty_tuple_obj};
 
 /******************************************************************************/
 /* generator wrapper                                                          */
@@ -91,11 +91,11 @@
     mp_obj_fun_bc_t *self_fun = MP_OBJ_TO_PTR(self_in);
 
     // Determine start of prelude, and extract n_state from it
-    uintptr_t prelude_offset = ((uintptr_t*)self_fun->bytecode)[0];
+    uintptr_t prelude_offset = ((uintptr_t *)self_fun->bytecode)[0];
     #if MICROPY_EMIT_NATIVE_PRELUDE_AS_BYTES_OBJ
     // Prelude is in bytes object in const_table, at index prelude_offset
     mp_obj_str_t *prelude_bytes = MP_OBJ_TO_PTR(self_fun->const_table[prelude_offset]);
-    prelude_offset = (const byte*)prelude_bytes->data - self_fun->bytecode;
+    prelude_offset = (const byte *)prelude_bytes->data - self_fun->bytecode;
     #endif
     const uint8_t *ip = self_fun->bytecode + prelude_offset;
     size_t n_state, n_exc_stack_unused, scope_flags, n_pos_args, n_kwonly_args, n_def_args;
@@ -110,7 +110,7 @@
     // Parse the input arguments and set up the code state
     o->pend_exc = mp_const_none;
     o->code_state.fun_bc = self_fun;
-    o->code_state.ip = (const byte*)prelude_offset;
+    o->code_state.ip = (const byte *)prelude_offset;
     o->code_state.n_state = n_state;
     mp_setup_code_state(&o->code_state, n_args, n_kw, args);
 
@@ -118,8 +118,8 @@
     o->code_state.exc_sp_idx = MP_CODE_STATE_EXC_SP_IDX_SENTINEL;
 
     // Prepare the generator instance for execution
-    uintptr_t start_offset = ((uintptr_t*)self_fun->bytecode)[1];
-    o->code_state.ip = MICROPY_MAKE_POINTER_CALLABLE((void*)(self_fun->bytecode + start_offset));
+    uintptr_t start_offset = ((uintptr_t *)self_fun->bytecode)[1];
+    o->code_state.ip = MICROPY_MAKE_POINTER_CALLABLE((void *)(self_fun->bytecode + start_offset));
 
     return MP_OBJ_FROM_PTR(o);
 }
@@ -188,9 +188,9 @@
     #if MICROPY_EMIT_NATIVE
     if (self->code_state.exc_sp_idx == MP_CODE_STATE_EXC_SP_IDX_SENTINEL) {
         // A native generator, with entry point 2 words into the "bytecode" pointer
-        typedef uintptr_t (*mp_fun_native_gen_t)(void*, mp_obj_t);
-        mp_fun_native_gen_t fun = MICROPY_MAKE_POINTER_CALLABLE((const void*)(self->code_state.fun_bc->bytecode + 2 * sizeof(uintptr_t)));
-        ret_kind = fun((void*)&self->code_state, throw_value);
+        typedef uintptr_t (*mp_fun_native_gen_t)(void *, mp_obj_t);
+        mp_fun_native_gen_t fun = MICROPY_MAKE_POINTER_CALLABLE((const void *)(self->code_state.fun_bc->bytecode + 2 * sizeof(uintptr_t)));
+        ret_kind = fun((void *)&self->code_state, throw_value);
     } else
     #endif
     {
@@ -347,5 +347,5 @@
     .unary_op = mp_generic_unary_op,
     .getiter = mp_identity_getiter,
     .iternext = gen_instance_iternext,
-    .locals_dict = (mp_obj_dict_t*)&gen_instance_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&gen_instance_locals_dict,
 };
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
index ec41c2c..54e27b8 100644
--- a/py/objgetitemiter.c
+++ b/py/objgetitemiter.c
@@ -46,7 +46,7 @@
         return value;
     } else {
         // an exception was raised
-        mp_obj_type_t *t = (mp_obj_type_t*)((mp_obj_base_t*)nlr.ret_val)->type;
+        mp_obj_type_t *t = (mp_obj_type_t *)((mp_obj_base_t *)nlr.ret_val)->type;
         if (t == &mp_type_StopIteration || t == &mp_type_IndexError) {
             // return MP_OBJ_STOP_ITERATION instead of raising
             return MP_OBJ_STOP_ITERATION;
@@ -67,7 +67,7 @@
 // args are those returned from mp_load_method_maybe (ie either an attribute or a method)
 mp_obj_t mp_obj_new_getitem_iter(mp_obj_t *args, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_getitem_iter_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t*)iter_buf;
+    mp_obj_getitem_iter_t *o = (mp_obj_getitem_iter_t *)iter_buf;
     o->base.type = &it_type;
     o->args[0] = args[0];
     o->args[1] = args[1];
diff --git a/py/objint.c b/py/objint.c
index 2fdcf58..da51e5a 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -57,10 +57,10 @@
                 size_t l;
                 const char *s = mp_obj_str_get_data(args[0], &l);
                 return mp_parse_num_integer(s, l, 0, NULL);
-#if MICROPY_PY_BUILTINS_FLOAT
+            #if MICROPY_PY_BUILTINS_FLOAT
             } else if (mp_obj_is_float(args[0])) {
                 return mp_obj_new_int_from_float(mp_obj_float_get(args[0]));
-#endif
+            #endif
             } else {
                 return mp_unary_op(MP_UNARY_OP_INT, args[0]);
             }
@@ -86,26 +86,26 @@
 STATIC mp_fp_as_int_class_t mp_classify_fp_as_int(mp_float_t val) {
     union {
         mp_float_t f;
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
+        #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
         uint32_t i;
-#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
+        #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
         uint32_t i[2];
-#endif
+        #endif
     } u = {val};
 
     uint32_t e;
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
+    #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
     e = u.i;
-#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
+    #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
     e = u.i[MP_ENDIANNESS_LITTLE];
-#endif
+    #endif
 #define MP_FLOAT_SIGN_SHIFT_I32 ((MP_FLOAT_FRAC_BITS + MP_FLOAT_EXP_BITS) % 32)
 #define MP_FLOAT_EXP_SHIFT_I32 (MP_FLOAT_FRAC_BITS % 32)
 
     if (e & (1U << MP_FLOAT_SIGN_SHIFT_I32)) {
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
+        #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
         e |= u.i[MP_ENDIANNESS_BIG] != 0;
-#endif
+        #endif
         if ((e & ~(1 << MP_FLOAT_SIGN_SHIFT_I32)) == 0) {
             // handle case of -0 (when sign is set but rest of bits are zero)
             e = 0;
@@ -120,16 +120,16 @@
     if (e <= ((8 * sizeof(uintptr_t) + MP_FLOAT_EXP_BIAS - 3) << MP_FLOAT_EXP_SHIFT_I32)) {
         return MP_FP_CLASS_FIT_SMALLINT;
     }
-#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
+    #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
     if (e <= (((sizeof(long long) * BITS_PER_BYTE) + MP_FLOAT_EXP_BIAS - 2) << MP_FLOAT_EXP_SHIFT_I32)) {
         return MP_FP_CLASS_FIT_LONGINT;
     }
-#endif
-#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
+    #endif
+    #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
     return MP_FP_CLASS_FIT_LONGINT;
-#else
+    #else
     return MP_FP_CLASS_OVERFLOW;
-#endif
+    #endif
 }
 #undef MP_FLOAT_SIGN_SHIFT_I32
 #undef MP_FLOAT_EXP_SHIFT_I32
@@ -218,7 +218,7 @@
 // The resulting formatted string will be returned from this function and the
 // formatted size will be in *fmt_size.
 char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
-                           int base, const char *prefix, char base_char, char comma) {
+    int base, const char *prefix, char base_char, char comma) {
     fmt_int_t num;
     #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_NONE
     // Only have small ints; get the integer value to format.
@@ -392,7 +392,7 @@
     mp_buffer_info_t bufinfo;
     mp_get_buffer_raise(args[1], &bufinfo, MP_BUFFER_READ);
 
-    const byte* buf = (const byte*)bufinfo.buf;
+    const byte *buf = (const byte *)bufinfo.buf;
     int delta = 1;
     if (args[2] == MP_OBJ_NEW_QSTR(MP_QSTR_little)) {
         buf += bufinfo.len - 1;
@@ -428,7 +428,7 @@
 
     vstr_t vstr;
     vstr_init_len(&vstr, len);
-    byte *data = (byte*)vstr.buf;
+    byte *data = (byte *)vstr.buf;
     memset(data, 0, len);
 
     #if MICROPY_LONGINT_IMPL != MICROPY_LONGINT_IMPL_NONE
@@ -460,5 +460,5 @@
     .make_new = mp_obj_int_make_new,
     .unary_op = mp_obj_int_unary_op,
     .binary_op = mp_obj_int_binary_op,
-    .locals_dict = (mp_obj_dict_t*)&int_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&int_locals_dict,
 };
diff --git a/py/objint.h b/py/objint.h
index 4b95acd..c475238 100644
--- a/py/objint.h
+++ b/py/objint.h
@@ -31,11 +31,11 @@
 
 typedef struct _mp_obj_int_t {
     mp_obj_base_t base;
-#if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
+    #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_LONGLONG
     mp_longint_impl_t val;
-#elif MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
+    #elif MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
     mpz_t mpz;
-#endif
+    #endif
 } mp_obj_int_t;
 
 extern const mp_obj_int_t mp_maxsize_obj;
@@ -50,9 +50,9 @@
 
 void mp_obj_int_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind);
 char *mp_obj_int_formatted(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
-                           int base, const char *prefix, char base_char, char comma);
+    int base, const char *prefix, char base_char, char comma);
 char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
-                                int base, const char *prefix, char base_char, char comma);
+    int base, const char *prefix, char base_char, char comma);
 mp_int_t mp_obj_int_hash(mp_obj_t self_in);
 mp_obj_t mp_obj_int_from_bytes_impl(bool big_endian, size_t len, const byte *buf);
 void mp_obj_int_to_bytes_impl(mp_obj_t self_in, bool big_endian, size_t len, byte *buf);
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 37e2d6b..c34415a 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -95,15 +95,20 @@
 mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_int_t *o = o_in;
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(o->val != 0);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(o->val != 0);
 
         // truncate value to fit in mp_int_t, which gives the same hash as
         // small int if the value fits without truncation
-        case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT((mp_int_t)o->val);
+        case MP_UNARY_OP_HASH:
+            return MP_OBJ_NEW_SMALL_INT((mp_int_t)o->val);
 
-        case MP_UNARY_OP_POSITIVE: return o_in;
-        case MP_UNARY_OP_NEGATIVE: return mp_obj_new_int_from_ll(-o->val);
-        case MP_UNARY_OP_INVERT: return mp_obj_new_int_from_ll(~o->val);
+        case MP_UNARY_OP_POSITIVE:
+            return o_in;
+        case MP_UNARY_OP_NEGATIVE:
+            return mp_obj_new_int_from_ll(-o->val);
+        case MP_UNARY_OP_INVERT:
+            return mp_obj_new_int_from_ll(~o->val);
         case MP_UNARY_OP_ABS: {
             mp_obj_int_t *self = MP_OBJ_TO_PTR(o_in);
             if (self->val >= 0) {
@@ -114,7 +119,8 @@
             self->val = -self->val;
             return MP_OBJ_FROM_PTR(self);
         }
-        default: return MP_OBJ_NULL; // op not supported
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -126,13 +132,13 @@
         lhs_val = MP_OBJ_SMALL_INT_VALUE(lhs_in);
     } else {
         assert(mp_obj_is_type(lhs_in, &mp_type_int));
-        lhs_val = ((mp_obj_int_t*)lhs_in)->val;
+        lhs_val = ((mp_obj_int_t *)lhs_in)->val;
     }
 
     if (mp_obj_is_small_int(rhs_in)) {
         rhs_val = MP_OBJ_SMALL_INT_VALUE(rhs_in);
     } else if (mp_obj_is_type(rhs_in, &mp_type_int)) {
-        rhs_val = ((mp_obj_int_t*)rhs_in)->val;
+        rhs_val = ((mp_obj_int_t *)rhs_in)->val;
     } else {
         // delegate to generic function to check for extra cases
         return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 7b2bcc9..5fd558f 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -68,7 +68,7 @@
 // *FORMAT-ON*
 const mp_obj_int_t mp_maxsize_obj = {
     {&mp_type_int},
-    {.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t*)maxsize_dig}
+    {.fixed_dig = 1, .len = NUM_DIG, .alloc = NUM_DIG, .dig = (mpz_dig_t *)maxsize_dig}
 };
 #undef DIG_MASK
 #undef NUM_DIG
@@ -91,7 +91,7 @@
 //
 // This particular routine should only be called for the mpz representation of the int.
 char *mp_obj_int_formatted_impl(char **buf, size_t *buf_size, size_t *fmt_size, mp_const_obj_t self_in,
-                                int base, const char *prefix, char base_char, char comma) {
+    int base, const char *prefix, char base_char, char comma) {
     assert(mp_obj_is_type(self_in, &mp_type_int));
     const mp_obj_int_t *self = MP_OBJ_TO_PTR(self_in);
 
@@ -144,11 +144,20 @@
 mp_obj_t mp_obj_int_unary_op(mp_unary_op_t op, mp_obj_t o_in) {
     mp_obj_int_t *o = MP_OBJ_TO_PTR(o_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(!mpz_is_zero(&o->mpz));
-        case MP_UNARY_OP_HASH: return MP_OBJ_NEW_SMALL_INT(mpz_hash(&o->mpz));
-        case MP_UNARY_OP_POSITIVE: return o_in;
-        case MP_UNARY_OP_NEGATIVE: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_neg_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); }
-        case MP_UNARY_OP_INVERT: { mp_obj_int_t *o2 = mp_obj_int_new_mpz(); mpz_not_inpl(&o2->mpz, &o->mpz); return MP_OBJ_FROM_PTR(o2); }
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(!mpz_is_zero(&o->mpz));
+        case MP_UNARY_OP_HASH:
+            return MP_OBJ_NEW_SMALL_INT(mpz_hash(&o->mpz));
+        case MP_UNARY_OP_POSITIVE:
+            return o_in;
+        case MP_UNARY_OP_NEGATIVE: { mp_obj_int_t *o2 = mp_obj_int_new_mpz();
+                                     mpz_neg_inpl(&o2->mpz, &o->mpz);
+                                     return MP_OBJ_FROM_PTR(o2);
+        }
+        case MP_UNARY_OP_INVERT: { mp_obj_int_t *o2 = mp_obj_int_new_mpz();
+                                   mpz_not_inpl(&o2->mpz, &o->mpz);
+                                   return MP_OBJ_FROM_PTR(o2);
+        }
         case MP_UNARY_OP_ABS: {
             mp_obj_int_t *self = MP_OBJ_TO_PTR(o_in);
             if (self->mpz.neg == 0) {
@@ -158,7 +167,8 @@
             mpz_abs_inpl(&self2->mpz, &self->mpz);
             return MP_OBJ_FROM_PTR(self2);
         }
-        default: return MP_OBJ_NULL; // op not supported
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -174,7 +184,7 @@
         zlhs = &z_int;
     } else {
         assert(mp_obj_is_type(lhs_in, &mp_type_int));
-        zlhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(lhs_in))->mpz;
+        zlhs = &((mp_obj_int_t *)MP_OBJ_TO_PTR(lhs_in))->mpz;
     }
 
     // if rhs is small int, then lhs was not (otherwise mp_binary_op handles it)
@@ -182,15 +192,15 @@
         mpz_init_fixed_from_int(&z_int, z_int_dig, MPZ_NUM_DIG_FOR_INT, MP_OBJ_SMALL_INT_VALUE(rhs_in));
         zrhs = &z_int;
     } else if (mp_obj_is_type(rhs_in, &mp_type_int)) {
-        zrhs = &((mp_obj_int_t*)MP_OBJ_TO_PTR(rhs_in))->mpz;
-#if MICROPY_PY_BUILTINS_FLOAT
+        zrhs = &((mp_obj_int_t *)MP_OBJ_TO_PTR(rhs_in))->mpz;
+    #if MICROPY_PY_BUILTINS_FLOAT
     } else if (mp_obj_is_float(rhs_in)) {
         return mp_obj_float_binary_op(op, mpz_as_float(zlhs), rhs_in);
-#endif
-#if MICROPY_PY_BUILTINS_COMPLEX
+    #endif
+    #if MICROPY_PY_BUILTINS_COMPLEX
     } else if (mp_obj_is_type(rhs_in, &mp_type_complex)) {
         return mp_obj_complex_binary_op(op, mpz_as_float(zlhs), 0, rhs_in);
-#endif
+    #endif
     } else {
         // delegate to generic function to check for extra cases
         return mp_obj_int_binary_op_extra_cases(op, lhs_in, rhs_in);
@@ -226,10 +236,11 @@
             case MP_BINARY_OP_FLOOR_DIVIDE:
             case MP_BINARY_OP_INPLACE_FLOOR_DIVIDE: {
                 if (mpz_is_zero(zrhs)) {
-                    zero_division_error:
+                zero_division_error:
                     mp_raise_msg(&mp_type_ZeroDivisionError, "divide by zero");
                 }
-                mpz_t rem; mpz_init_zero(&rem);
+                mpz_t rem;
+                mpz_init_zero(&rem);
                 mpz_divmod_inpl(&res->mpz, &rem, zlhs, zrhs);
                 mpz_deinit(&rem);
                 break;
@@ -239,7 +250,8 @@
                 if (mpz_is_zero(zrhs)) {
                     goto zero_division_error;
                 }
-                mpz_t quo; mpz_init_zero(&quo);
+                mpz_t quo;
+                mpz_init_zero(&quo);
                 mpz_divmod_inpl(&quo, &res->mpz, zlhs, zrhs);
                 mpz_deinit(&quo);
                 break;
@@ -345,9 +357,15 @@
 
         mpz_pow3_inpl(&(res_p->mpz), lhs, rhs, mod);
 
-        if (lhs == &l_temp) { mpz_deinit(lhs); }
-        if (rhs == &r_temp) { mpz_deinit(rhs); }
-        if (mod == &m_temp) { mpz_deinit(mod); }
+        if (lhs == &l_temp) {
+            mpz_deinit(lhs);
+        }
+        if (rhs == &r_temp) {
+            mpz_deinit(rhs);
+        }
+        if (mod == &m_temp) {
+            mpz_deinit(mod);
+        }
         return result;
     }
 }
diff --git a/py/objlist.c b/py/objlist.c
index 00afcd5..38329e0 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -88,15 +88,18 @@
 STATIC mp_obj_t list_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(self->len != 0);
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(self->len);
         #if MICROPY_PY_SYS_GETSIZEOF
         case MP_UNARY_OP_SIZEOF: {
             size_t sz = sizeof(*self) + sizeof(mp_obj_t) * self->alloc;
             return MP_OBJ_NEW_SMALL_INT(sz);
         }
         #endif
-        default: return MP_OBJ_NULL; // op not supported
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -153,7 +156,7 @@
 STATIC mp_obj_t list_subscr(mp_obj_t self_in, mp_obj_t index, mp_obj_t value) {
     if (value == MP_OBJ_NULL) {
         // delete
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
             mp_bound_slice_t slice;
@@ -163,20 +166,20 @@
 
             mp_int_t len_adj = slice.start - slice.stop;
             assert(len_adj <= 0);
-            mp_seq_replace_slice_no_grow(self->items, self->len, slice.start, slice.stop, self->items/*NULL*/, 0, sizeof(*self->items));
+            mp_seq_replace_slice_no_grow(self->items, self->len, slice.start, slice.stop, self->items /*NULL*/, 0, sizeof(*self->items));
             // Clear "freed" elements at the end of list
             mp_seq_clear(self->items, self->len + len_adj, self->len, sizeof(*self->items));
             self->len += len_adj;
             return mp_const_none;
         }
-#endif
+        #endif
         mp_obj_t args[2] = {self_in, index};
         list_pop(2, args);
         return mp_const_none;
     } else if (value == MP_OBJ_SENTINEL) {
         // load
         mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_bound_slice_t slice;
             if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
@@ -186,14 +189,15 @@
             mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t);
             return MP_OBJ_FROM_PTR(res);
         }
-#endif
+        #endif
         size_t index_val = mp_get_index(self->base.type, self->len, index, false);
         return self->items[index_val];
     } else {
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
-            size_t value_len; mp_obj_t *value_items;
+            size_t value_len;
+            mp_obj_t *value_items;
             mp_obj_get_array(value, &value_len, &value_items);
             mp_bound_slice_t slice_out;
             if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice_out)) {
@@ -219,7 +223,7 @@
             self->len += len_adj;
             return mp_const_none;
         }
-#endif
+        #endif
         mp_obj_list_store(self_in, index, value);
         return mp_const_none;
     }
@@ -275,7 +279,7 @@
     // Clear stale pointer from slot which just got freed to prevent GC issues
     self->items[self->len] = MP_OBJ_NULL;
     if (self->alloc > LIST_MIN_ALLOC && self->alloc > 2 * self->len) {
-        self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc/2);
+        self->items = m_renew(mp_obj_t, self->items, self->alloc, self->alloc / 2);
         self->alloc /= 2;
     }
     return ret;
@@ -288,9 +292,13 @@
         mp_obj_t *t = tail;
         mp_obj_t v = key_fn == MP_OBJ_NULL ? tail[0] : mp_call_function_1(key_fn, tail[0]); // get pivot using key_fn
         for (;;) {
-            do ++h; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == MP_OBJ_NULL ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result);
-            do --t; while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == MP_OBJ_NULL ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result);
-            if (h >= t) break;
+            do {++h;
+            } while (h < t && mp_binary_op(MP_BINARY_OP_LESS, key_fn == MP_OBJ_NULL ? h[0] : mp_call_function_1(key_fn, h[0]), v) == binop_less_result);
+            do {--t;
+            } while (h < t && mp_binary_op(MP_BINARY_OP_LESS, v, key_fn == MP_OBJ_NULL ? t[0] : mp_call_function_1(key_fn, t[0])) == binop_less_result);
+            if (h >= t) {
+                break;
+            }
             mp_obj_t x = h[0];
             h[0] = t[0];
             t[0] = x;
@@ -321,15 +329,15 @@
         mp_arg_val_t key, reverse;
     } args;
     mp_arg_parse_all(n_args - 1, pos_args + 1, kw_args,
-        MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t*)&args);
+        MP_ARRAY_SIZE(allowed_args), allowed_args, (mp_arg_val_t *)&args);
 
     mp_check_self(mp_obj_is_type(pos_args[0], &mp_type_list));
     mp_obj_list_t *self = MP_OBJ_TO_PTR(pos_args[0]);
 
     if (self->len > 1) {
         mp_quicksort(self->items, self->items + self->len - 1,
-                     args.key.u_obj == mp_const_none ? MP_OBJ_NULL : args.key.u_obj,
-                     args.reverse.u_bool ? mp_const_false : mp_const_true);
+            args.key.u_obj == mp_const_none ? MP_OBJ_NULL : args.key.u_obj,
+            args.reverse.u_bool ? mp_const_false : mp_const_true);
     }
 
     return mp_const_none;
@@ -369,19 +377,19 @@
     // insert has its own strange index logic
     mp_int_t index = MP_OBJ_SMALL_INT_VALUE(idx);
     if (index < 0) {
-         index += self->len;
+        index += self->len;
     }
     if (index < 0) {
-         index = 0;
+        index = 0;
     }
     if ((size_t)index > self->len) {
-         index = self->len;
+        index = self->len;
     }
 
     mp_obj_list_append(self_in, mp_const_none);
 
-    for (mp_int_t i = self->len-1; i > index; i--) {
-         self->items[i] = self->items[i-1];
+    for (mp_int_t i = self->len - 1; i > index; i--) {
+        self->items[i] = self->items[i - 1];
     }
     self->items[index] = obj;
 
@@ -402,10 +410,10 @@
     mp_obj_list_t *self = MP_OBJ_TO_PTR(self_in);
 
     mp_int_t len = self->len;
-    for (mp_int_t i = 0; i < len/2; i++) {
-         mp_obj_t a = self->items[i];
-         self->items[i] = self->items[len-i-1];
-         self->items[len-i-1] = a;
+    for (mp_int_t i = 0; i < len / 2; i++) {
+        mp_obj_t a = self->items[i];
+        self->items[i] = self->items[len - i - 1];
+        self->items[len - i - 1] = a;
     }
 
     return mp_const_none;
@@ -448,7 +456,7 @@
     .binary_op = list_binary_op,
     .subscr = list_subscr,
     .getiter = list_getiter,
-    .locals_dict = (mp_obj_dict_t*)&list_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&list_locals_dict,
 };
 
 void mp_obj_list_init(mp_obj_list_t *o, size_t n) {
@@ -518,7 +526,7 @@
 
 mp_obj_t mp_obj_new_list_iterator(mp_obj_t list, size_t cur, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_list_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_list_it_t *o = (mp_obj_list_it_t*)iter_buf;
+    mp_obj_list_it_t *o = (mp_obj_list_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = list_it_iternext;
     o->list = list;
diff --git a/py/objmodule.c b/py/objmodule.c
index 81558a0..7904700 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -45,7 +45,7 @@
         module_name = mp_obj_str_get_str(elem->value);
     }
 
-#if MICROPY_PY___FILE__
+    #if MICROPY_PY___FILE__
     // If we store __file__ to imported modules then try to lookup this
     // symbol to give more information about the module.
     elem = mp_map_lookup(&self->globals->map, MP_OBJ_NEW_QSTR(MP_QSTR___file__), MP_MAP_LOOKUP);
@@ -53,7 +53,7 @@
         mp_printf(print, "<module '%s' from '%s'>", module_name, mp_obj_str_get_str(elem->value));
         return;
     }
-#endif
+    #endif
 
     mp_printf(print, "<module '%s'>", module_name);
 }
@@ -140,93 +140,93 @@
     { MP_ROM_QSTR(MP_QSTR_builtins), MP_ROM_PTR(&mp_module_builtins) },
     { MP_ROM_QSTR(MP_QSTR_micropython), MP_ROM_PTR(&mp_module_micropython) },
 
-#if MICROPY_PY_IO
+    #if MICROPY_PY_IO
     { MP_ROM_QSTR(MP_QSTR_uio), MP_ROM_PTR(&mp_module_io) },
-#endif
-#if MICROPY_PY_COLLECTIONS
+    #endif
+    #if MICROPY_PY_COLLECTIONS
     { MP_ROM_QSTR(MP_QSTR_ucollections), MP_ROM_PTR(&mp_module_collections) },
-#endif
-#if MICROPY_PY_STRUCT
+    #endif
+    #if MICROPY_PY_STRUCT
     { MP_ROM_QSTR(MP_QSTR_ustruct), MP_ROM_PTR(&mp_module_ustruct) },
-#endif
+    #endif
 
-#if MICROPY_PY_BUILTINS_FLOAT
-#if MICROPY_PY_MATH
+    #if MICROPY_PY_BUILTINS_FLOAT
+    #if MICROPY_PY_MATH
     { MP_ROM_QSTR(MP_QSTR_math), MP_ROM_PTR(&mp_module_math) },
-#endif
-#if MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH
+    #endif
+    #if MICROPY_PY_BUILTINS_COMPLEX && MICROPY_PY_CMATH
     { MP_ROM_QSTR(MP_QSTR_cmath), MP_ROM_PTR(&mp_module_cmath) },
-#endif
-#endif
-#if MICROPY_PY_SYS
+    #endif
+    #endif
+    #if MICROPY_PY_SYS
     { MP_ROM_QSTR(MP_QSTR_sys), MP_ROM_PTR(&mp_module_sys) },
-#endif
-#if MICROPY_PY_GC && MICROPY_ENABLE_GC
+    #endif
+    #if MICROPY_PY_GC && MICROPY_ENABLE_GC
     { MP_ROM_QSTR(MP_QSTR_gc), MP_ROM_PTR(&mp_module_gc) },
-#endif
-#if MICROPY_PY_THREAD
+    #endif
+    #if MICROPY_PY_THREAD
     { MP_ROM_QSTR(MP_QSTR__thread), MP_ROM_PTR(&mp_module_thread) },
-#endif
+    #endif
 
     // extmod modules
 
-#if MICROPY_PY_UERRNO
+    #if MICROPY_PY_UERRNO
     { MP_ROM_QSTR(MP_QSTR_uerrno), MP_ROM_PTR(&mp_module_uerrno) },
-#endif
-#if MICROPY_PY_UCTYPES
+    #endif
+    #if MICROPY_PY_UCTYPES
     { MP_ROM_QSTR(MP_QSTR_uctypes), MP_ROM_PTR(&mp_module_uctypes) },
-#endif
-#if MICROPY_PY_UZLIB
+    #endif
+    #if MICROPY_PY_UZLIB
     { MP_ROM_QSTR(MP_QSTR_uzlib), MP_ROM_PTR(&mp_module_uzlib) },
-#endif
-#if MICROPY_PY_UJSON
+    #endif
+    #if MICROPY_PY_UJSON
     { MP_ROM_QSTR(MP_QSTR_ujson), MP_ROM_PTR(&mp_module_ujson) },
-#endif
-#if MICROPY_PY_URE
+    #endif
+    #if MICROPY_PY_URE
     { MP_ROM_QSTR(MP_QSTR_ure), MP_ROM_PTR(&mp_module_ure) },
-#endif
-#if MICROPY_PY_UHEAPQ
+    #endif
+    #if MICROPY_PY_UHEAPQ
     { MP_ROM_QSTR(MP_QSTR_uheapq), MP_ROM_PTR(&mp_module_uheapq) },
-#endif
-#if MICROPY_PY_UTIMEQ
+    #endif
+    #if MICROPY_PY_UTIMEQ
     { MP_ROM_QSTR(MP_QSTR_utimeq), MP_ROM_PTR(&mp_module_utimeq) },
-#endif
-#if MICROPY_PY_UHASHLIB
+    #endif
+    #if MICROPY_PY_UHASHLIB
     { MP_ROM_QSTR(MP_QSTR_uhashlib), MP_ROM_PTR(&mp_module_uhashlib) },
-#endif
-#if MICROPY_PY_UCRYPTOLIB
+    #endif
+    #if MICROPY_PY_UCRYPTOLIB
     { MP_ROM_QSTR(MP_QSTR_ucryptolib), MP_ROM_PTR(&mp_module_ucryptolib) },
-#endif
-#if MICROPY_PY_UBINASCII
+    #endif
+    #if MICROPY_PY_UBINASCII
     { MP_ROM_QSTR(MP_QSTR_ubinascii), MP_ROM_PTR(&mp_module_ubinascii) },
-#endif
-#if MICROPY_PY_URANDOM
+    #endif
+    #if MICROPY_PY_URANDOM
     { MP_ROM_QSTR(MP_QSTR_urandom), MP_ROM_PTR(&mp_module_urandom) },
-#endif
-#if MICROPY_PY_USELECT
+    #endif
+    #if MICROPY_PY_USELECT
     { MP_ROM_QSTR(MP_QSTR_uselect), MP_ROM_PTR(&mp_module_uselect) },
-#endif
-#if MICROPY_PY_USSL
+    #endif
+    #if MICROPY_PY_USSL
     { MP_ROM_QSTR(MP_QSTR_ussl), MP_ROM_PTR(&mp_module_ussl) },
-#endif
-#if MICROPY_PY_LWIP
+    #endif
+    #if MICROPY_PY_LWIP
     { MP_ROM_QSTR(MP_QSTR_lwip), MP_ROM_PTR(&mp_module_lwip) },
-#endif
-#if MICROPY_PY_UWEBSOCKET
+    #endif
+    #if MICROPY_PY_UWEBSOCKET
     { MP_ROM_QSTR(MP_QSTR_uwebsocket), MP_ROM_PTR(&mp_module_uwebsocket) },
-#endif
-#if MICROPY_PY_WEBREPL
+    #endif
+    #if MICROPY_PY_WEBREPL
     { MP_ROM_QSTR(MP_QSTR__webrepl), MP_ROM_PTR(&mp_module_webrepl) },
-#endif
-#if MICROPY_PY_FRAMEBUF
+    #endif
+    #if MICROPY_PY_FRAMEBUF
     { MP_ROM_QSTR(MP_QSTR_framebuf), MP_ROM_PTR(&mp_module_framebuf) },
-#endif
-#if MICROPY_PY_BTREE
+    #endif
+    #if MICROPY_PY_BTREE
     { MP_ROM_QSTR(MP_QSTR_btree), MP_ROM_PTR(&mp_module_btree) },
-#endif
-#if MICROPY_PY_BLUETOOTH
+    #endif
+    #if MICROPY_PY_BLUETOOTH
     { MP_ROM_QSTR(MP_QSTR_ubluetooth), MP_ROM_PTR(&mp_module_ubluetooth) },
-#endif
+    #endif
 
     // extra builtin modules as defined by a port
     MICROPY_PORT_BUILTIN_MODULES
@@ -247,7 +247,7 @@
 
     if (el == NULL) {
         // module not found, look for builtin module names
-        el = mp_map_lookup((mp_map_t*)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP);
+        el = mp_map_lookup((mp_map_t *)&mp_builtin_module_map, MP_OBJ_NEW_QSTR(module_name), MP_MAP_LOOKUP);
         if (el == NULL) {
             return MP_OBJ_NULL;
         }
@@ -267,7 +267,7 @@
 // Search for u"foo" in built-in modules, return MP_OBJ_NULL if not found
 mp_obj_t mp_module_search_umodule(const char *module_str) {
     for (size_t i = 0; i < MP_ARRAY_SIZE(mp_builtin_module_table); ++i) {
-        const mp_map_elem_t *entry = (const mp_map_elem_t*)&mp_builtin_module_table[i];
+        const mp_map_elem_t *entry = (const mp_map_elem_t *)&mp_builtin_module_table[i];
         const char *key = qstr_str(MP_OBJ_QSTR_VALUE(entry->key));
         if (key[0] == 'u' && strcmp(&key[1], module_str) == 0) {
             return (mp_obj_t)entry->value;
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index 8e714aa..a4ac19f 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -46,7 +46,7 @@
 #if MICROPY_PY_COLLECTIONS_NAMEDTUPLE__ASDICT
 STATIC mp_obj_t namedtuple_asdict(mp_obj_t self_in) {
     mp_obj_namedtuple_t *self = MP_OBJ_TO_PTR(self_in);
-    const qstr *fields = ((mp_obj_namedtuple_type_t*)self->tuple.base.type)->fields;
+    const qstr *fields = ((mp_obj_namedtuple_type_t *)self->tuple.base.type)->fields;
     mp_obj_t dict = mp_obj_new_dict(self->tuple.len);
     //make it an OrderedDict
     mp_obj_dict_t *dictObj = MP_OBJ_TO_PTR(dict);
@@ -64,7 +64,7 @@
     (void)kind;
     mp_obj_namedtuple_t *o = MP_OBJ_TO_PTR(o_in);
     mp_printf(print, "%q", o->tuple.base.type->name);
-    const qstr *fields = ((mp_obj_namedtuple_type_t*)o->tuple.base.type)->fields;
+    const qstr *fields = ((mp_obj_namedtuple_type_t *)o->tuple.base.type)->fields;
     mp_obj_attrtuple_print_helper(print, fields, &o->tuple);
 }
 
@@ -79,7 +79,7 @@
             return;
         }
         #endif
-        size_t id = mp_obj_namedtuple_find_field((mp_obj_namedtuple_type_t*)self->tuple.base.type, attr);
+        size_t id = mp_obj_namedtuple_find_field((mp_obj_namedtuple_type_t *)self->tuple.base.type, attr);
         if (id == (size_t)-1) {
             return;
         }
@@ -92,7 +92,7 @@
 }
 
 STATIC mp_obj_t namedtuple_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args) {
-    const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t*)type_in;
+    const mp_obj_namedtuple_type_t *type = (const mp_obj_namedtuple_type_t *)type_in;
     size_t num_fields = type->n_fields;
     if (n_args + n_kw != num_fields) {
         if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
diff --git a/py/objobject.c b/py/objobject.c
index 71301dc..62a3366 100644
--- a/py/objobject.c
+++ b/py/objobject.c
@@ -49,7 +49,7 @@
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(object___init___obj, object___init__);
 
 STATIC mp_obj_t object___new__(mp_obj_t cls) {
-    if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t*)MP_OBJ_TO_PTR(cls))) {
+    if (!mp_obj_is_type(cls, &mp_type_type) || !mp_obj_is_instance_type((mp_obj_type_t *)MP_OBJ_TO_PTR(cls))) {
         mp_raise_TypeError("arg must be user-type");
     }
     // This executes only "__new__" part of instance creation.
@@ -117,6 +117,6 @@
     .name = MP_QSTR_object,
     .make_new = object_make_new,
     #if MICROPY_CPYTHON_COMPAT
-    .locals_dict = (mp_obj_dict_t*)&object_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&object_locals_dict,
     #endif
 };
diff --git a/py/objproperty.c b/py/objproperty.c
index 2a7844b..8d2c292 100644
--- a/py/objproperty.c
+++ b/py/objproperty.c
@@ -58,7 +58,7 @@
 
 STATIC mp_obj_t property_getter(mp_obj_t self_in, mp_obj_t getter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
-    *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in);
+    *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[0] = getter;
     return MP_OBJ_FROM_PTR(p2);
 }
@@ -67,7 +67,7 @@
 
 STATIC mp_obj_t property_setter(mp_obj_t self_in, mp_obj_t setter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
-    *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in);
+    *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[1] = setter;
     return MP_OBJ_FROM_PTR(p2);
 }
@@ -76,7 +76,7 @@
 
 STATIC mp_obj_t property_deleter(mp_obj_t self_in, mp_obj_t deleter) {
     mp_obj_property_t *p2 = m_new_obj(mp_obj_property_t);
-    *p2 = *(mp_obj_property_t*)MP_OBJ_TO_PTR(self_in);
+    *p2 = *(mp_obj_property_t *)MP_OBJ_TO_PTR(self_in);
     p2->proxy[2] = deleter;
     return MP_OBJ_FROM_PTR(p2);
 }
@@ -95,7 +95,7 @@
     { &mp_type_type },
     .name = MP_QSTR_property,
     .make_new = property_make_new,
-    .locals_dict = (mp_obj_dict_t*)&property_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&property_locals_dict,
 };
 
 const mp_obj_t *mp_obj_property_get(mp_obj_t self_in) {
diff --git a/py/objrange.c b/py/objrange.c
index 6c3097a..9727d48 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -59,7 +59,7 @@
 
 STATIC mp_obj_t mp_obj_new_range_iterator(mp_int_t cur, mp_int_t stop, mp_int_t step, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_range_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_range_it_t *o = (mp_obj_range_it_t*)iter_buf;
+    mp_obj_range_it_t *o = (mp_obj_range_it_t *)iter_buf;
     o->base.type = &range_it_type;
     o->cur = cur;
     o->stop = stop;
@@ -132,9 +132,12 @@
     mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
     mp_int_t len = range_len(self);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(len > 0);
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(len);
-        default: return MP_OBJ_NULL; // op not supported
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(len > 0);
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(len);
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -152,7 +155,7 @@
         && (lhs_len == 0
             || (lhs->start == rhs->start
                 && (lhs_len == 1 || lhs->step == rhs->step)))
-    );
+        );
 }
 #endif
 
@@ -161,7 +164,7 @@
         // load
         mp_obj_range_t *self = MP_OBJ_TO_PTR(self_in);
         mp_int_t len = range_len(self);
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_bound_slice_t slice;
             mp_seq_get_fast_slice_indexes(len, index, &slice);
@@ -176,7 +179,7 @@
             }
             return MP_OBJ_FROM_PTR(o);
         }
-#endif
+        #endif
         size_t index_val = mp_get_index(self->base.type, len, index, false);
         return MP_OBJ_NEW_SMALL_INT(self->start + index_val * self->step);
     } else {
@@ -218,7 +221,7 @@
     #endif
     .subscr = range_subscr,
     .getiter = range_getiter,
-#if MICROPY_PY_BUILTINS_RANGE_ATTRS
+    #if MICROPY_PY_BUILTINS_RANGE_ATTRS
     .attr = range_attr,
-#endif
+    #endif
 };
diff --git a/py/objset.c b/py/objset.c
index 48d6caf..da56f9a 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -47,9 +47,9 @@
 
 STATIC bool is_set_or_frozenset(mp_obj_t o) {
     return mp_obj_is_type(o, &mp_type_set)
-#if MICROPY_PY_BUILTINS_FROZENSET
-        || mp_obj_is_type(o, &mp_type_frozenset)
-#endif
+           #if MICROPY_PY_BUILTINS_FROZENSET
+           || mp_obj_is_type(o, &mp_type_frozenset)
+           #endif
     ;
 }
 
@@ -121,7 +121,7 @@
                 mp_obj_set_store(set, item);
             }
             // Set actual set/frozenset type
-            ((mp_obj_set_t*)MP_OBJ_TO_PTR(set))->base.type = type;
+            ((mp_obj_set_t *)MP_OBJ_TO_PTR(set))->base.type = type;
             return set;
         }
     }
@@ -144,7 +144,7 @@
 
 STATIC mp_obj_t set_getiter(mp_obj_t set_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_set_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_set_it_t *o = (mp_obj_set_it_t*)iter_buf;
+    mp_obj_set_it_t *o = (mp_obj_set_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = set_it_iternext;
     o->set = (mp_obj_set_t *)MP_OBJ_TO_PTR(set_in);
@@ -205,7 +205,7 @@
         if (self == other) {
             set_clear(self);
         } else {
-            mp_set_t *self_set = &((mp_obj_set_t*)MP_OBJ_TO_PTR(self))->set;
+            mp_set_t *self_set = &((mp_obj_set_t *)MP_OBJ_TO_PTR(self))->set;
             mp_obj_t iter = mp_getiter(other, NULL);
             mp_obj_t next;
             while ((next = mp_iternext(iter)) != MP_OBJ_STOP_ITERATION) {
@@ -426,9 +426,11 @@
 STATIC mp_obj_t set_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_set_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->set.used != 0);
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->set.used);
-#if MICROPY_PY_BUILTINS_FROZENSET
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(self->set.used != 0);
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(self->set.used);
+        #if MICROPY_PY_BUILTINS_FROZENSET
         case MP_UNARY_OP_HASH:
             if (mp_obj_is_type(self_in, &mp_type_frozenset)) {
                 // start hash with unique value
@@ -443,8 +445,9 @@
                 }
                 return MP_OBJ_NEW_SMALL_INT(hash);
             }
-#endif
-        default: return MP_OBJ_NULL; // op not supported
+        #endif
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -544,7 +547,7 @@
     .unary_op = set_unary_op,
     .binary_op = set_binary_op,
     .getiter = set_getiter,
-    .locals_dict = (mp_obj_dict_t*)&set_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&set_locals_dict,
 };
 
 #if MICROPY_PY_BUILTINS_FROZENSET
@@ -570,7 +573,7 @@
     .unary_op = set_unary_op,
     .binary_op = set_binary_op,
     .getiter = set_getiter,
-    .locals_dict = (mp_obj_dict_t*)&frozenset_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&frozenset_locals_dict,
 };
 #endif
 
diff --git a/py/objslice.c b/py/objslice.c
index 86ee03e..d1c23cb 100644
--- a/py/objslice.c
+++ b/py/objslice.c
@@ -96,11 +96,11 @@
     { &mp_type_type },
     .name = MP_QSTR_slice,
     .print = slice_print,
-#if MICROPY_PY_BUILTINS_SLICE_ATTRS
+    #if MICROPY_PY_BUILTINS_SLICE_ATTRS
     .attr = slice_attr,
-#elif MICROPY_PY_BUILTINS_SLICE_INDICES
-    .locals_dict = (mp_obj_dict_t*)&slice_locals_dict,
-#endif
+    #elif MICROPY_PY_BUILTINS_SLICE_INDICES
+    .locals_dict = (mp_obj_dict_t *)&slice_locals_dict,
+    #endif
 };
 
 mp_obj_t mp_obj_new_slice(mp_obj_t ostart, mp_obj_t ostop, mp_obj_t ostep) {
diff --git a/py/objstr.c b/py/objstr.c
index 7919a4d..aba0349 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -133,11 +133,11 @@
 }
 
 mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     if (n_kw != 0) {
         mp_arg_error_unimpl_kw();
     }
-#endif
+    #endif
 
     mp_arg_check_num(n_args, n_kw, 0, 3, false);
 
@@ -168,7 +168,7 @@
                 #endif
 
                 // Check if a qstr with this data already exists
-                qstr q = qstr_find_strn((const char*)str_data, str_len);
+                qstr q = qstr_find_strn((const char *)str_data, str_len);
                 if (q != MP_QSTRnull) {
                     return MP_OBJ_NEW_QSTR(q);
                 }
@@ -412,7 +412,7 @@
 #if !MICROPY_PY_BUILTINS_STR_UNICODE
 // objstrunicode defines own version
 const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len,
-                             mp_obj_t index, bool is_slice) {
+    mp_obj_t index, bool is_slice) {
     size_t index_val = mp_get_index(type, self_len, index, is_slice);
     return self_data + index_val;
 }
@@ -424,7 +424,7 @@
     GET_STR_DATA_LEN(self_in, self_data, self_len);
     if (value == MP_OBJ_SENTINEL) {
         // load
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_bound_slice_t slice;
             if (!mp_seq_get_fast_slice_indexes(self_len, index, &slice)) {
@@ -432,13 +432,13 @@
             }
             return mp_obj_new_str_of_type(type, self_data + slice.start, slice.stop - slice.start);
         }
-#endif
+        #endif
         size_t index_val = mp_get_index(type, self_len, index, false);
         // If we have unicode enabled the type will always be bytes, so take the short cut.
         if (MICROPY_PY_BUILTINS_STR_UNICODE || type == &mp_type_bytes) {
             return MP_OBJ_NEW_SMALL_INT(self_data[index_val]);
         } else {
-            return mp_obj_new_str_via_qstr((char*)&self_data[index_val], 1);
+            return mp_obj_new_str_via_qstr((char *)&self_data[index_val], 1);
         }
     } else {
         return MP_OBJ_NULL; // op not supported
@@ -480,7 +480,7 @@
     // make joined string
     vstr_t vstr;
     vstr_init_len(&vstr, required_len);
-    byte *data = (byte*)vstr.buf;
+    byte *data = (byte *)vstr.buf;
     for (size_t i = 0; i < seq_len; i++) {
         if (i > 0) {
             memcpy(data, sep_str, sep_len);
@@ -515,15 +515,21 @@
         // sep not given, so separate on whitespace
 
         // Initial whitespace is not counted as split, so we pre-do it
-        while (s < top && unichar_isspace(*s)) s++;
+        while (s < top && unichar_isspace(*s)) {
+            s++;
+        }
         while (s < top && splits != 0) {
             const byte *start = s;
-            while (s < top && !unichar_isspace(*s)) s++;
+            while (s < top && !unichar_isspace(*s)) {
+                s++;
+            }
             mp_obj_list_append(res, mp_obj_new_str_of_type(self_type, start, s - start));
             if (s >= top) {
                 break;
             }
-            while (s < top && unichar_isspace(*s)) s++;
+            while (s < top && unichar_isspace(*s)) {
+                s++;
+            }
             if (splits > 0) {
                 splits--;
             }
@@ -915,19 +921,19 @@
 
 STATIC bool arg_looks_numeric(mp_obj_t arg) {
     return arg_looks_integer(arg)
-#if MICROPY_PY_BUILTINS_FLOAT
-        || mp_obj_is_float(arg)
-#endif
+           #if MICROPY_PY_BUILTINS_FLOAT
+           || mp_obj_is_float(arg)
+           #endif
     ;
 }
 
 #if MICROPY_PY_BUILTINS_STR_OP_MODULO
 STATIC mp_obj_t arg_as_int(mp_obj_t arg) {
-#if MICROPY_PY_BUILTINS_FLOAT
+    #if MICROPY_PY_BUILTINS_FLOAT
     if (mp_obj_is_float(arg)) {
         return mp_obj_new_int_from_float(mp_obj_float_get(arg));
     }
-#endif
+    #endif
     return arg;
 }
 #endif
@@ -1065,7 +1071,8 @@
                 *arg_i = -1;
             } else {
                 const char *lookup;
-                for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++);
+                for (lookup = field_name; lookup < field_name_top && *lookup != '.' && *lookup != '['; lookup++) {;
+                }
                 mp_obj_t field_q = mp_obj_new_str_via_qstr(field_name, lookup - field_name); // should it be via qstr?
                 field_name = lookup;
                 mp_map_elem_t *key_elem = mp_map_lookup(kwargs, field_q, MP_MAP_LOOKUP);
@@ -1210,9 +1217,15 @@
         }
 
         switch (align) {
-            case '<': flags |= PF_FLAG_LEFT_ADJUST;     break;
-            case '=': flags |= PF_FLAG_PAD_AFTER_SIGN;  break;
-            case '^': flags |= PF_FLAG_CENTER_ADJUST;   break;
+            case '<':
+                flags |= PF_FLAG_LEFT_ADJUST;
+                break;
+            case '=':
+                flags |= PF_FLAG_PAD_AFTER_SIGN;
+                break;
+            case '^':
+                flags |= PF_FLAG_CENTER_ADJUST;
+                break;
         }
 
         if (arg_looks_integer(arg)) {
@@ -1221,8 +1234,7 @@
                     mp_print_mp_int(&print, arg, 2, 'a', flags, fill, width, 0);
                     continue;
 
-                case 'c':
-                {
+                case 'c': {
                     char ch = mp_obj_get_int(arg);
                     mp_print_strn(&print, &ch, 1, flags, fill, width);
                     continue;
@@ -1308,7 +1320,7 @@
             }
 
             switch (type) {
-#if MICROPY_PY_BUILTINS_FLOAT
+                #if MICROPY_PY_BUILTINS_FLOAT
                 case 'e':
                 case 'E':
                 case 'f':
@@ -1326,9 +1338,9 @@
                     #define F100 100.0
                     #endif
                     mp_print_float(&print, mp_obj_get_float(arg) * F100, 'f', flags, fill, width, precision);
-                    #undef F100
+#undef F100
                     break;
-#endif
+                #endif
 
                 default:
                     if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
@@ -1386,7 +1398,7 @@
 
     GET_STR_DATA_LEN(args[0], str, len);
     int arg_i = 0;
-    vstr_t vstr = mp_obj_str_format_helper((const char*)str, (const char*)str + len, &arg_i, n_args, args, kwargs);
+    vstr_t vstr = mp_obj_str_format_helper((const char *)str, (const char *)str + len, &arg_i, n_args, args, kwargs);
     return mp_obj_new_str_from_vstr(mp_obj_get_type(args[0]), &vstr);
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(str_format_obj, 1, mp_obj_str_format);
@@ -1434,7 +1446,7 @@
                 }
                 ++str;
             }
-            mp_obj_t k_obj = mp_obj_new_str_via_qstr((const char*)key, str - key);
+            mp_obj_t k_obj = mp_obj_new_str_via_qstr((const char *)key, str - key);
             arg = mp_obj_dict_get(dict, k_obj);
             str++;
         }
@@ -1443,14 +1455,20 @@
         char fill = ' ';
         int alt = 0;
         while (str < top) {
-            if (*str == '-')      flags |= PF_FLAG_LEFT_ADJUST;
-            else if (*str == '+') flags |= PF_FLAG_SHOW_SIGN;
-            else if (*str == ' ') flags |= PF_FLAG_SPACE_SIGN;
-            else if (*str == '#') alt = PF_FLAG_SHOW_PREFIX;
-            else if (*str == '0') {
+            if (*str == '-') {
+                flags |= PF_FLAG_LEFT_ADJUST;
+            } else if (*str == '+') {
+                flags |= PF_FLAG_SHOW_SIGN;
+            } else if (*str == ' ') {
+                flags |= PF_FLAG_SPACE_SIGN;
+            } else if (*str == '#') {
+                alt = PF_FLAG_SHOW_PREFIX;
+            } else if (*str == '0') {
                 flags |= PF_FLAG_PAD_AFTER_SIGN;
                 fill = '0';
-            } else break;
+            } else {
+                break;
+            }
             str++;
         }
         // parse width, if it exists
@@ -1463,7 +1481,7 @@
                 width = mp_obj_get_int(args[arg_i++]);
                 str++;
             } else {
-                str = (const byte*)str_to_int((const char*)str, (const char*)top, &width);
+                str = (const byte *)str_to_int((const char *)str, (const char *)top, &width);
             }
         }
         int prec = -1;
@@ -1477,13 +1495,13 @@
                     str++;
                 } else {
                     prec = 0;
-                    str = (const byte*)str_to_int((const char*)str, (const char*)top, &prec);
+                    str = (const byte *)str_to_int((const char *)str, (const char *)top, &prec);
                 }
             }
         }
 
         if (str >= top) {
-incomplete_format:
+        incomplete_format:
             if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
                 terse_str_format_value_error();
             } else {
@@ -1494,7 +1512,7 @@
         // Tuple value lookup
         if (arg == MP_OBJ_NULL) {
             if (arg_i >= n_args) {
-not_enough_args:
+            not_enough_args:
                 mp_raise_TypeError("format string needs more arguments");
             }
             arg = args[arg_i++];
@@ -1522,7 +1540,7 @@
                 mp_print_mp_int(&print, arg_as_int(arg), 10, 'a', flags, fill, width, prec);
                 break;
 
-#if MICROPY_PY_BUILTINS_FLOAT
+            #if MICROPY_PY_BUILTINS_FLOAT
             case 'e':
             case 'E':
             case 'f':
@@ -1531,7 +1549,7 @@
             case 'G':
                 mp_print_float(&print, mp_obj_get_float(arg), *str, flags, fill, width, prec);
                 break;
-#endif
+            #endif
 
             case 'o':
                 if (alt) {
@@ -1541,8 +1559,7 @@
                 break;
 
             case 'r':
-            case 's':
-            {
+            case 's': {
                 vstr_t arg_vstr;
                 mp_print_t arg_print;
                 vstr_init_print(&arg_vstr, 16, &arg_print);
@@ -1684,7 +1701,7 @@
             } else {
                 // substr found, allocate new string
                 vstr_init_len(&vstr, replaced_str_index);
-                data = (byte*)vstr.buf;
+                data = (byte *)vstr.buf;
                 assert(data != NULL);
             }
         } else {
@@ -1799,7 +1816,7 @@
     GET_STR_DATA_LEN(self_in, self_data, self_len);
     vstr_t vstr;
     vstr_init_len(&vstr, self_len);
-    byte *data = (byte*)vstr.buf;
+    byte *data = (byte *)vstr.buf;
     for (size_t i = 0; i < self_len; i++) {
         *data++ = op(*self_data++);
     }
@@ -1907,7 +1924,7 @@
 mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
     if (flags == MP_BUFFER_READ) {
         GET_STR_DATA_LEN(self_in, str_data, str_len);
-        bufinfo->buf = (void*)str_data;
+        bufinfo->buf = (void *)str_data;
         bufinfo->len = str_len;
         bufinfo->typecode = 'B'; // bytes should be unsigned, so should unicode byte-access
         return 0;
@@ -1918,7 +1935,7 @@
 }
 
 STATIC const mp_rom_map_elem_t str8_locals_dict_table[] = {
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     { MP_ROM_QSTR(MP_QSTR_decode), MP_ROM_PTR(&bytes_decode_obj) },
     #if !MICROPY_PY_BUILTINS_STR_UNICODE
     // If we have separate unicode type, then here we have methods only
@@ -1928,7 +1945,7 @@
     // methods (which should do type checking at runtime).
     { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) },
     #endif
-#endif
+    #endif
     { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) },
     { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) },
     { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) },
@@ -1979,7 +1996,7 @@
     .subscr = bytes_subscr,
     .getiter = mp_obj_new_str_iterator,
     .buffer_p = { .get_buffer = mp_obj_str_get_buffer },
-    .locals_dict = (mp_obj_dict_t*)&str8_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&str8_locals_dict,
 };
 #endif
 
@@ -1993,16 +2010,16 @@
     .subscr = bytes_subscr,
     .getiter = mp_obj_new_bytes_iterator,
     .buffer_p = { .get_buffer = mp_obj_str_get_buffer },
-    .locals_dict = (mp_obj_dict_t*)&str8_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&str8_locals_dict,
 };
 
 // The zero-length bytes object, with data that includes a null-terminating byte
-const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, (const byte*)""};
+const mp_obj_str_t mp_const_empty_bytes_obj = {{&mp_type_bytes}, 0, 0, (const byte *)""};
 
 // Create a str/bytes object using the given data.  New memory is allocated and
 // the data is copied across.  This function should only be used if the type is bytes,
 // or if the type is str and the string data is known to be not interned.
-mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte* data, size_t len) {
+mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte *data, size_t len) {
     mp_obj_str_t *o = m_new_obj(mp_obj_str_t);
     o->base.type = type;
     o->len = len;
@@ -2019,16 +2036,16 @@
 // Create a str/bytes object using the given data.  If the type is str and the string
 // data is already interned, then a qstr object is returned.  Otherwise new memory is
 // allocated for the object and the data is copied across.
-mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len) {
+mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte *data, size_t len) {
     if (type == &mp_type_str) {
-        return mp_obj_new_str((const char*)data, len);
+        return mp_obj_new_str((const char *)data, len);
     } else {
         return mp_obj_new_bytes(data, len);
     }
 }
 
 // Create a str using a qstr to store the data; may use existing or new qstr.
-mp_obj_t mp_obj_new_str_via_qstr(const char* data, size_t len) {
+mp_obj_t mp_obj_new_str_via_qstr(const char *data, size_t len) {
     return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len));
 }
 
@@ -2050,41 +2067,41 @@
     mp_obj_str_t *o = m_new_obj(mp_obj_str_t);
     o->base.type = type;
     o->len = vstr->len;
-    o->hash = qstr_compute_hash((byte*)vstr->buf, vstr->len);
+    o->hash = qstr_compute_hash((byte *)vstr->buf, vstr->len);
     if (vstr->len + 1 == vstr->alloc) {
-        o->data = (byte*)vstr->buf;
+        o->data = (byte *)vstr->buf;
     } else {
-        o->data = (byte*)m_renew(char, vstr->buf, vstr->alloc, vstr->len + 1);
+        o->data = (byte *)m_renew(char, vstr->buf, vstr->alloc, vstr->len + 1);
     }
-    ((byte*)o->data)[o->len] = '\0'; // add null byte
+    ((byte *)o->data)[o->len] = '\0'; // add null byte
     vstr->buf = NULL;
     vstr->alloc = 0;
     return MP_OBJ_FROM_PTR(o);
 }
 
-mp_obj_t mp_obj_new_str(const char* data, size_t len) {
+mp_obj_t mp_obj_new_str(const char *data, size_t len) {
     qstr q = qstr_find_strn(data, len);
     if (q != MP_QSTRnull) {
         // qstr with this data already exists
         return MP_OBJ_NEW_QSTR(q);
     } else {
         // no existing qstr, don't make one
-        return mp_obj_new_str_copy(&mp_type_str, (const byte*)data, len);
+        return mp_obj_new_str_copy(&mp_type_str, (const byte *)data, len);
     }
 }
 
 mp_obj_t mp_obj_str_intern(mp_obj_t str) {
     GET_STR_DATA_LEN(str, data, len);
-    return mp_obj_new_str_via_qstr((const char*)data, len);
+    return mp_obj_new_str_via_qstr((const char *)data, len);
 }
 
 mp_obj_t mp_obj_str_intern_checked(mp_obj_t obj) {
     size_t len;
     const char *data = mp_obj_str_get_data(obj, &len);
-    return mp_obj_new_str_via_qstr((const char*)data, len);
+    return mp_obj_new_str_via_qstr((const char *)data, len);
 }
 
-mp_obj_t mp_obj_new_bytes(const byte* data, size_t len) {
+mp_obj_t mp_obj_new_bytes(const byte *data, size_t len) {
     return mp_obj_new_str_copy(&mp_type_bytes, data, len);
 }
 
@@ -2125,7 +2142,7 @@
         return MP_OBJ_QSTR_VALUE(self_in);
     } else if (mp_obj_is_type(self_in, &mp_type_str)) {
         mp_obj_str_t *self = MP_OBJ_TO_PTR(self_in);
-        return qstr_from_strn((char*)self->data, self->len);
+        return qstr_from_strn((char *)self->data, self->len);
     } else {
         bad_implicit_conversion(self_in);
     }
@@ -2137,7 +2154,7 @@
     if (mp_obj_is_str_or_bytes(self_in)) {
         GET_STR_DATA_LEN(self_in, s, l);
         (void)l; // len unused
-        return (const char*)s;
+        return (const char *)s;
     } else {
         bad_implicit_conversion(self_in);
     }
@@ -2147,7 +2164,7 @@
     if (mp_obj_is_str_or_bytes(self_in)) {
         GET_STR_DATA_LEN(self_in, s, l);
         *len = l;
-        return (const char*)s;
+        return (const char *)s;
     } else {
         bad_implicit_conversion(self_in);
     }
@@ -2158,8 +2175,8 @@
     if (mp_obj_is_qstr(self_in)) {
         return qstr_data(MP_OBJ_QSTR_VALUE(self_in), len);
     } else {
-        *len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(self_in))->len;
-        return ((mp_obj_str_t*)MP_OBJ_TO_PTR(self_in))->data;
+        *len = ((mp_obj_str_t *)MP_OBJ_TO_PTR(self_in))->len;
+        return ((mp_obj_str_t *)MP_OBJ_TO_PTR(self_in))->data;
     }
 }
 #endif
@@ -2179,7 +2196,7 @@
     mp_obj_str8_it_t *self = MP_OBJ_TO_PTR(self_in);
     GET_STR_DATA_LEN(self->str, str, len);
     if (self->cur < len) {
-        mp_obj_t o_out = mp_obj_new_str_via_qstr((const char*)str + self->cur, 1);
+        mp_obj_t o_out = mp_obj_new_str_via_qstr((const char *)str + self->cur, 1);
         self->cur += 1;
         return o_out;
     } else {
@@ -2189,7 +2206,7 @@
 
 STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf;
+    mp_obj_str8_it_t *o = (mp_obj_str8_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = str_it_iternext;
     o->str = str;
@@ -2212,7 +2229,7 @@
 
 mp_obj_t mp_obj_new_bytes_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_str8_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_str8_it_t *o = (mp_obj_str8_it_t*)iter_buf;
+    mp_obj_str8_it_t *o = (mp_obj_str8_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = bytes_it_iternext;
     o->str = str;
diff --git a/py/objstr.h b/py/objstr.h
index ba300cc..8c450ba 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -36,18 +36,18 @@
     const byte *data;
 } mp_obj_str_t;
 
-#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte*)str}
+#define MP_DEFINE_STR_OBJ(obj_name, str) mp_obj_str_t obj_name = {{&mp_type_str}, 0, sizeof(str) - 1, (const byte *)str}
 
 // use this macro to extract the string hash
 // warning: the hash can be 0, meaning invalid, and must then be explicitly computed from the data
 #define GET_STR_HASH(str_obj_in, str_hash) \
     mp_uint_t str_hash; if (mp_obj_is_qstr(str_obj_in)) \
-    { str_hash = qstr_hash(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_hash = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->hash; }
+    { str_hash = qstr_hash(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_hash = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->hash; }
 
 // use this macro to extract the string length
 #define GET_STR_LEN(str_obj_in, str_len) \
     size_t str_len; if (mp_obj_is_qstr(str_obj_in)) \
-    { str_len = qstr_len(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; }
+    { str_len = qstr_len(MP_OBJ_QSTR_VALUE(str_obj_in)); } else { str_len = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->len; }
 
 // use this macro to extract the string data and length
 #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_C || MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
@@ -58,21 +58,21 @@
 #define GET_STR_DATA_LEN(str_obj_in, str_data, str_len) \
     const byte *str_data; size_t str_len; if (mp_obj_is_qstr(str_obj_in)) \
     { str_data = qstr_data(MP_OBJ_QSTR_VALUE(str_obj_in), &str_len); } \
-    else { str_len = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t*)MP_OBJ_TO_PTR(str_obj_in))->data; }
+    else { str_len = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->len; str_data = ((mp_obj_str_t *)MP_OBJ_TO_PTR(str_obj_in))->data; }
 #endif
 
 mp_obj_t mp_obj_str_make_new(const mp_obj_type_t *type_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
 void mp_str_print_json(const mp_print_t *print, const byte *str_data, size_t str_len);
 mp_obj_t mp_obj_str_format(size_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
 mp_obj_t mp_obj_str_split(size_t n_args, const mp_obj_t *args);
-mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte* data, size_t len);
-mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, size_t len);
+mp_obj_t mp_obj_new_str_copy(const mp_obj_type_t *type, const byte *data, size_t len);
+mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte *data, size_t len);
 
 mp_obj_t mp_obj_str_binary_op(mp_binary_op_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
 mp_int_t mp_obj_str_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags);
 
 const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len,
-                             mp_obj_t index, bool is_slice);
+    mp_obj_t index, bool is_slice);
 const byte *find_subbytes(const byte *haystack, size_t hlen, const byte *needle, size_t nlen, int direction);
 
 MP_DECLARE_CONST_FUN_OBJ_VAR_BETWEEN(str_encode_obj);
diff --git a/py/objstringio.c b/py/objstringio.c
index cca4a81..98808e3 100644
--- a/py/objstringio.c
+++ b/py/objstringio.c
@@ -114,7 +114,7 @@
     mp_obj_stringio_t *o = MP_OBJ_TO_PTR(o_in);
     switch (request) {
         case MP_STREAM_SEEK: {
-            struct mp_stream_seek_t *s = (struct mp_stream_seek_t*)arg;
+            struct mp_stream_seek_t *s = (struct mp_stream_seek_t *)arg;
             mp_uint_t ref = 0;
             switch (s->whence) {
                 case MP_SEEK_CUR:
@@ -166,7 +166,7 @@
     mp_obj_stringio_t *self = MP_OBJ_TO_PTR(self_in);
     check_stringio_is_open(self);
     // TODO: Try to avoid copying string
-    return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte*)self->vstr->buf, self->vstr->len);
+    return mp_obj_new_str_of_type(STREAM_TO_CONTENT_TYPE(self), (byte *)self->vstr->buf, self->vstr->len);
 }
 STATIC MP_DEFINE_CONST_FUN_OBJ_1(stringio_getvalue_obj, stringio_getvalue);
 
@@ -252,7 +252,7 @@
     .getiter = mp_identity_getiter,
     .iternext = mp_stream_unbuffered_iter,
     .protocol = &stringio_stream_p,
-    .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&stringio_locals_dict,
 };
 
 #if MICROPY_PY_IO_BYTESIO
@@ -270,7 +270,7 @@
     .getiter = mp_identity_getiter,
     .iternext = mp_stream_unbuffered_iter,
     .protocol = &bytesio_stream_p,
-    .locals_dict = (mp_obj_dict_t*)&stringio_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&stringio_locals_dict,
 };
 #endif
 
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index c9bd6ee..defcbe4 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -113,7 +113,7 @@
 // Convert an index into a pointer to its lead byte. Out of bounds indexing will raise IndexError or
 // be capped to the first/last character of the string, depending on is_slice.
 const byte *str_index_to_ptr(const mp_obj_type_t *type, const byte *self_data, size_t self_len,
-                             mp_obj_t index, bool is_slice) {
+    mp_obj_t index, bool is_slice) {
     // All str functions also handle bytes objects, and they call str_index_to_ptr(),
     // so it must handle bytes.
     if (type == &mp_type_bytes) {
@@ -132,8 +132,7 @@
         mp_raise_msg_varg(&mp_type_TypeError, "string indices must be integers, not %s", mp_obj_get_type_str(index));
     }
     const byte *s, *top = self_data + self_len;
-    if (i < 0)
-    {
+    if (i < 0) {
         // Negative indexing is performed by counting from the end of the string.
         for (s = top - 1; i; --s) {
             if (s < self_data) {
@@ -181,7 +180,7 @@
     GET_STR_DATA_LEN(self_in, self_data, self_len);
     if (value == MP_OBJ_SENTINEL) {
         // load
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_obj_t ostart, ostop, ostep;
             mp_obj_slice_t *slice = MP_OBJ_TO_PTR(index);
@@ -211,7 +210,7 @@
             }
             return mp_obj_new_str_of_type(type, (const byte *)pstart, pstop - pstart);
         }
-#endif
+        #endif
         const byte *s = str_index_to_ptr(type, self_data, self_len, index, false);
         int len = 1;
         if (UTF8_IS_NONASCII(*s)) {
@@ -220,16 +219,16 @@
                 ++len;
             }
         }
-        return mp_obj_new_str_via_qstr((const char*)s, len); // This will create a one-character string
+        return mp_obj_new_str_via_qstr((const char *)s, len); // This will create a one-character string
     } else {
         return MP_OBJ_NULL; // op not supported
     }
 }
 
 STATIC const mp_rom_map_elem_t struni_locals_dict_table[] = {
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     { MP_ROM_QSTR(MP_QSTR_encode), MP_ROM_PTR(&str_encode_obj) },
-#endif
+    #endif
     { MP_ROM_QSTR(MP_QSTR_find), MP_ROM_PTR(&str_find_obj) },
     { MP_ROM_QSTR(MP_QSTR_rfind), MP_ROM_PTR(&str_rfind_obj) },
     { MP_ROM_QSTR(MP_QSTR_index), MP_ROM_PTR(&str_index_obj) },
@@ -278,7 +277,7 @@
     .subscr = str_subscr,
     .getiter = mp_obj_new_str_iterator,
     .buffer_p = { .get_buffer = mp_obj_str_get_buffer },
-    .locals_dict = (mp_obj_dict_t*)&struni_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&struni_locals_dict,
 };
 
 /******************************************************************************/
@@ -297,7 +296,7 @@
     if (self->cur < len) {
         const byte *cur = str + self->cur;
         const byte *end = utf8_next_char(str + self->cur);
-        mp_obj_t o_out = mp_obj_new_str_via_qstr((const char*)cur, end - cur);
+        mp_obj_t o_out = mp_obj_new_str_via_qstr((const char *)cur, end - cur);
         self->cur += end - cur;
         return o_out;
     } else {
@@ -307,7 +306,7 @@
 
 STATIC mp_obj_t mp_obj_new_str_iterator(mp_obj_t str, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_str_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_str_it_t *o = (mp_obj_str_it_t*)iter_buf;
+    mp_obj_str_it_t *o = (mp_obj_str_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = str_it_iternext;
     o->str = str;
diff --git a/py/objtuple.c b/py/objtuple.c
index e3f37eb..77e70a1 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -122,7 +122,8 @@
 mp_obj_t mp_obj_tuple_unary_op(mp_unary_op_t op, mp_obj_t self_in) {
     mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
     switch (op) {
-        case MP_UNARY_OP_BOOL: return mp_obj_new_bool(self->len != 0);
+        case MP_UNARY_OP_BOOL:
+            return mp_obj_new_bool(self->len != 0);
         case MP_UNARY_OP_HASH: {
             // start hash with pointer to empty tuple, to make it fairly unique
             mp_int_t hash = (mp_int_t)mp_const_empty_tuple;
@@ -131,8 +132,10 @@
             }
             return MP_OBJ_NEW_SMALL_INT(hash);
         }
-        case MP_UNARY_OP_LEN: return MP_OBJ_NEW_SMALL_INT(self->len);
-        default: return MP_OBJ_NULL; // op not supported
+        case MP_UNARY_OP_LEN:
+            return MP_OBJ_NEW_SMALL_INT(self->len);
+        default:
+            return MP_OBJ_NULL;      // op not supported
     }
 }
 
@@ -178,7 +181,7 @@
     if (value == MP_OBJ_SENTINEL) {
         // load
         mp_obj_tuple_t *self = MP_OBJ_TO_PTR(self_in);
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         if (mp_obj_is_type(index, &mp_type_slice)) {
             mp_bound_slice_t slice;
             if (!mp_seq_get_fast_slice_indexes(self->len, index, &slice)) {
@@ -188,7 +191,7 @@
             mp_seq_copy(res->items, self->items + slice.start, res->len, mp_obj_t);
             return MP_OBJ_FROM_PTR(res);
         }
-#endif
+        #endif
         size_t index_value = mp_get_index(self->base.type, self->len, index, false);
         return self->items[index_value];
     } else {
@@ -226,7 +229,7 @@
     .binary_op = mp_obj_tuple_binary_op,
     .subscr = mp_obj_tuple_subscr,
     .getiter = mp_obj_tuple_getiter,
-    .locals_dict = (mp_obj_dict_t*)&tuple_locals_dict,
+    .locals_dict = (mp_obj_dict_t *)&tuple_locals_dict,
 };
 
 // the zero-length tuple
@@ -283,7 +286,7 @@
 
 mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in, mp_obj_iter_buf_t *iter_buf) {
     assert(sizeof(mp_obj_tuple_it_t) <= sizeof(mp_obj_iter_buf_t));
-    mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t*)iter_buf;
+    mp_obj_tuple_it_t *o = (mp_obj_tuple_it_t *)iter_buf;
     o->base.type = &mp_type_polymorph_iter;
     o->iternext = tuple_it_iternext;
     o->tuple = MP_OBJ_TO_PTR(o_in);
diff --git a/py/objtuple.h b/py/objtuple.h
index 74cde88..cc42aa6 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -52,7 +52,7 @@
     const mp_rom_obj_tuple_t tuple_obj_name = { \
         .base = {&mp_type_attrtuple}, \
         .len = nitems, \
-        .items = { __VA_ARGS__ , MP_ROM_PTR((void*)fields) } \
+        .items = { __VA_ARGS__, MP_ROM_PTR((void *)fields) } \
     }
 
 #if MICROPY_PY_COLLECTIONS
diff --git a/py/objtype.c b/py/objtype.c
index 206e80f..0f49ad2 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -42,7 +42,7 @@
 #endif
 
 #define ENABLE_SPECIAL_ACCESSORS \
-    (MICROPY_PY_DESCRIPTORS  || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
+    (MICROPY_PY_DESCRIPTORS || MICROPY_PY_DELATTR_SETATTR || MICROPY_PY_BUILTINS_PROPERTY)
 
 STATIC mp_obj_t static_class_method_make_new(const mp_obj_type_t *self_in, size_t n_args, size_t n_kw, const mp_obj_t *args);
 
@@ -63,7 +63,7 @@
             // No parents so end search here.
             return count;
         #if MICROPY_MULTIPLE_INHERITANCE
-        } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
+        } else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
             // Multiple parents, search through them all recursively.
             const mp_obj_tuple_t *parent_tuple = type->parent;
             const mp_obj_t *item = parent_tuple->items;
@@ -133,7 +133,7 @@
     bool is_type;
 };
 
-STATIC void mp_obj_class_lookup(struct class_lookup_data  *lookup, const mp_obj_type_t *type) {
+STATIC void mp_obj_class_lookup(struct class_lookup_data *lookup, const mp_obj_type_t *type) {
     assert(lookup->dest[0] == MP_OBJ_NULL);
     assert(lookup->dest[1] == MP_OBJ_NULL);
     for (;;) {
@@ -143,7 +143,7 @@
         // this should not be applied to class types, as will result in extra
         // lookup either.
         if (lookup->meth_offset != 0 && mp_obj_is_native_type(type)) {
-            if (*(void**)((char*)type + lookup->meth_offset) != NULL) {
+            if (*(void **)((char *)type + lookup->meth_offset) != NULL) {
                 DEBUG_printf("mp_obj_class_lookup: Matched special meth slot (off=%d) for %s\n",
                     lookup->meth_offset, qstr_str(lookup->attr));
                 lookup->dest[0] = MP_OBJ_SENTINEL;
@@ -160,7 +160,7 @@
                 if (lookup->is_type) {
                     // If we look up a class method, we need to return original type for which we
                     // do a lookup, not a (base) type in which we found the class method.
-                    const mp_obj_type_t *org_type = (const mp_obj_type_t*)lookup->obj;
+                    const mp_obj_type_t *org_type = (const mp_obj_type_t *)lookup->obj;
                     mp_convert_member_lookup(MP_OBJ_NULL, org_type, elem->value, lookup->dest);
                 } else {
                     mp_obj_instance_t *obj = lookup->obj;
@@ -173,7 +173,7 @@
                     }
                     mp_convert_member_lookup(obj_obj, type, elem->value, lookup->dest);
                 }
-#if DEBUG_PRINT
+                #if DEBUG_PRINT
                 DEBUG_printf("mp_obj_class_lookup: Returning: ");
                 mp_obj_print_helper(MICROPY_DEBUG_PRINTER, lookup->dest[0], PRINT_REPR);
                 if (lookup->dest[1] != MP_OBJ_NULL) {
@@ -181,7 +181,7 @@
                     DEBUG_printf(" <%s @%p>", mp_obj_get_type_str(lookup->dest[1]), MP_OBJ_TO_PTR(lookup->dest[1]));
                 }
                 DEBUG_printf("\n");
-#endif
+                #endif
                 return;
             }
         }
@@ -202,13 +202,13 @@
             DEBUG_printf("mp_obj_class_lookup: No more parents\n");
             return;
         #if MICROPY_MULTIPLE_INHERITANCE
-        } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
+        } else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
             const mp_obj_tuple_t *parent_tuple = type->parent;
             const mp_obj_t *item = parent_tuple->items;
             const mp_obj_t *top = item + parent_tuple->len - 1;
             for (; item < top; ++item) {
                 assert(mp_obj_is_type(*item, &mp_type_type));
-                mp_obj_type_t *bt = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item);
+                mp_obj_type_t *bt = (mp_obj_type_t *)MP_OBJ_TO_PTR(*item);
                 if (bt == &mp_type_object) {
                     // Not a "real" type
                     continue;
@@ -221,7 +221,7 @@
 
             // search last base (simple tail recursion elimination)
             assert(mp_obj_is_type(*item, &mp_type_type));
-            type = (mp_obj_type_t*)MP_OBJ_TO_PTR(*item);
+            type = (mp_obj_type_t *)MP_OBJ_TO_PTR(*item);
         #endif
         } else {
             type = type->parent;
@@ -586,7 +586,7 @@
         dest[0] = elem->value;
         return;
     }
-#if MICROPY_CPYTHON_COMPAT
+    #if MICROPY_CPYTHON_COMPAT
     if (attr == MP_QSTR___dict__) {
         // Create a new dict with a copy of the instance's map items.
         // This creates, unlike CPython, a 'read-only' __dict__: modifying
@@ -601,7 +601,7 @@
         dest[0] = attr_dict;
         return;
     }
-#endif
+    #endif
     struct class_lookup_data lookup = {
         .obj = self,
         .attr = attr,
@@ -1031,7 +1031,7 @@
         }
         #endif
         struct class_lookup_data lookup = {
-            .obj = (mp_obj_instance_t*)self,
+            .obj = (mp_obj_instance_t *)self,
             .attr = attr,
             .meth_offset = 0,
             .dest = dest,
@@ -1146,7 +1146,7 @@
         // abstract base class which would translate C-level protocol to
         // Python method calls, and any subclass inheriting from it will
         // support this feature.
-        o->protocol = ((mp_obj_type_t*)MP_OBJ_TO_PTR(bases_items[0]))->protocol;
+        o->protocol = ((mp_obj_type_t *)MP_OBJ_TO_PTR(bases_items[0]))->protocol;
 
         if (bases_len >= 2) {
             #if MICROPY_MULTIPLE_INHERITANCE
@@ -1223,7 +1223,7 @@
         mp_raise_TypeError(NULL);
     }
     mp_obj_super_t *o = m_new_obj(mp_obj_super_t);
-    *o = (mp_obj_super_t){{type_in}, args[0], args[1]};
+    *o = (mp_obj_super_t) {{type_in}, args[0], args[1]};
     return MP_OBJ_FROM_PTR(o);
 }
 
@@ -1256,7 +1256,7 @@
     if (type->parent == NULL) {
         // no parents, do nothing
     #if MICROPY_MULTIPLE_INHERITANCE
-    } else if (((mp_obj_base_t*)type->parent)->type == &mp_type_tuple) {
+    } else if (((mp_obj_base_t *)type->parent)->type == &mp_type_tuple) {
         const mp_obj_tuple_t *parent_tuple = type->parent;
         size_t len = parent_tuple->len;
         const mp_obj_t *items = parent_tuple->items;
@@ -1267,7 +1267,7 @@
                 // and we don't want to lookup native methods in object.
                 continue;
             }
-            mp_obj_class_lookup(&lookup, (mp_obj_type_t*)MP_OBJ_TO_PTR(items[i]));
+            mp_obj_class_lookup(&lookup, (mp_obj_type_t *)MP_OBJ_TO_PTR(items[i]));
             if (dest[0] != MP_OBJ_NULL) {
                 break;
             }
@@ -1330,7 +1330,7 @@
             // type has no parents
             return false;
         #if MICROPY_MULTIPLE_INHERITANCE
-        } else if (((mp_obj_base_t*)self->parent)->type == &mp_type_tuple) {
+        } else if (((mp_obj_base_t *)self->parent)->type == &mp_type_tuple) {
             // get the base objects (they should be type objects)
             const mp_obj_tuple_t *parent_tuple = self->parent;
             const mp_obj_t *item = parent_tuple->items;
@@ -1397,7 +1397,7 @@
     } else if (!mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(self_type), native_type)) {
         return MP_OBJ_NULL;
     } else {
-        mp_obj_instance_t *self = (mp_obj_instance_t*)MP_OBJ_TO_PTR(self_in);
+        mp_obj_instance_t *self = (mp_obj_instance_t *)MP_OBJ_TO_PTR(self_in);
         return self->subobj[0];
     }
 }
@@ -1411,7 +1411,7 @@
     mp_arg_check_num(n_args, n_kw, 1, 1, false);
 
     mp_obj_static_class_method_t *o = m_new_obj(mp_obj_static_class_method_t);
-    *o = (mp_obj_static_class_method_t){{self}, args[0]};
+    *o = (mp_obj_static_class_method_t) {{self}, args[0]};
     return MP_OBJ_FROM_PTR(o);
 }
 
diff --git a/py/pairheap.c b/py/pairheap.c
index caa51bf..a1eecec 100644
--- a/py/pairheap.c
+++ b/py/pairheap.c
@@ -31,9 +31,9 @@
 //   - LSB set: the node is the last of the children and points to its parent node
 //   - other: the node is a child and not the last child
 // The macros below help manage this pointer.
-#define NEXT_MAKE_RIGHTMOST_PARENT(parent) ((void*)((uintptr_t)(parent) | 1))
+#define NEXT_MAKE_RIGHTMOST_PARENT(parent) ((void *)((uintptr_t)(parent) | 1))
 #define NEXT_IS_RIGHTMOST_PARENT(next) ((uintptr_t)(next) & 1)
-#define NEXT_GET_RIGHTMOST_PARENT(next) ((void*)((uintptr_t)(next) & ~1))
+#define NEXT_GET_RIGHTMOST_PARENT(next) ((void *)((uintptr_t)(next) & ~1))
 
 // O(1), stable
 mp_pairheap_t *mp_pairheap_meld(mp_pairheap_lt_t lt, mp_pairheap_t *heap1, mp_pairheap_t *heap2) {
diff --git a/py/pairheap.h b/py/pairheap.h
index f9517f2..8a9138b 100644
--- a/py/pairheap.h
+++ b/py/pairheap.h
@@ -50,7 +50,7 @@
 } mp_pairheap_t;
 
 // This is the function for the less-than operation on nodes/elements.
-typedef int (*mp_pairheap_lt_t)(mp_pairheap_t*, mp_pairheap_t*);
+typedef int (*mp_pairheap_lt_t)(mp_pairheap_t *, mp_pairheap_t *);
 
 // Core functions.
 mp_pairheap_t *mp_pairheap_meld(mp_pairheap_lt_t lt, mp_pairheap_t *heap1, mp_pairheap_t *heap2);
diff --git a/py/parse.c b/py/parse.c
index 1174f5d..8b68fd3 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -260,7 +260,7 @@
 
     if (chunk != NULL && chunk->union_.used + num_bytes > chunk->alloc) {
         // not enough room at end of previously allocated chunk so try to grow
-        mp_parse_chunk_t *new_data = (mp_parse_chunk_t*)m_renew_maybe(byte, chunk,
+        mp_parse_chunk_t *new_data = (mp_parse_chunk_t *)m_renew_maybe(byte, chunk,
             sizeof(mp_parse_chunk_t) + chunk->alloc,
             sizeof(mp_parse_chunk_t) + chunk->alloc + num_bytes, false);
         if (new_data == NULL) {
@@ -283,7 +283,7 @@
         if (alloc < num_bytes) {
             alloc = num_bytes;
         }
-        chunk = (mp_parse_chunk_t*)m_new(byte, sizeof(mp_parse_chunk_t) + alloc);
+        chunk = (mp_parse_chunk_t *)m_new(byte, sizeof(mp_parse_chunk_t) + alloc);
         chunk->alloc = alloc;
         chunk->union_.used = 0;
         parser->cur_chunk = chunk;
@@ -322,12 +322,12 @@
 
 bool mp_parse_node_is_const_false(mp_parse_node_t pn) {
     return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_FALSE)
-        || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0);
+           || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) == 0);
 }
 
 bool mp_parse_node_is_const_true(mp_parse_node_t pn) {
     return MP_PARSE_NODE_IS_TOKEN_KIND(pn, MP_TOKEN_KW_TRUE)
-        || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) != 0);
+           || (MP_PARSE_NODE_IS_SMALL_INT(pn) && MP_PARSE_NODE_LEAF_SMALL_INT(pn) != 0);
 }
 
 bool mp_parse_node_get_int_maybe(mp_parse_node_t pn, mp_obj_t *o) {
@@ -335,7 +335,7 @@
         *o = MP_OBJ_NEW_SMALL_INT(MP_PARSE_NODE_LEAF_SMALL_INT(pn));
         return true;
     } else if (MP_PARSE_NODE_IS_STRUCT_KIND(pn, RULE_const_object)) {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
         // nodes are 32-bit pointers, but need to extract 64-bit object
         *o = (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32);
@@ -356,7 +356,7 @@
         *nodes = pn;
         return 1;
     } else {
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)(*pn);
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)(*pn);
         if (MP_PARSE_NODE_STRUCT_KIND(pns) != pn_kind) {
             *nodes = pn;
             return 1;
@@ -370,7 +370,7 @@
 #if MICROPY_DEBUG_PRINTERS
 void mp_parse_node_print(mp_parse_node_t pn, size_t indent) {
     if (MP_PARSE_NODE_IS_STRUCT(pn)) {
-        printf("[% 4d] ", (int)((mp_parse_node_struct_t*)pn)->source_line);
+        printf("[% 4d] ", (int)((mp_parse_node_struct_t *)pn)->source_line);
     } else {
         printf("       ");
     }
@@ -385,16 +385,23 @@
     } else if (MP_PARSE_NODE_IS_LEAF(pn)) {
         uintptr_t arg = MP_PARSE_NODE_LEAF_ARG(pn);
         switch (MP_PARSE_NODE_LEAF_KIND(pn)) {
-            case MP_PARSE_NODE_ID: printf("id(%s)\n", qstr_str(arg)); break;
-            case MP_PARSE_NODE_STRING: printf("str(%s)\n", qstr_str(arg)); break;
-            case MP_PARSE_NODE_BYTES: printf("bytes(%s)\n", qstr_str(arg)); break;
+            case MP_PARSE_NODE_ID:
+                printf("id(%s)\n", qstr_str(arg));
+                break;
+            case MP_PARSE_NODE_STRING:
+                printf("str(%s)\n", qstr_str(arg));
+                break;
+            case MP_PARSE_NODE_BYTES:
+                printf("bytes(%s)\n", qstr_str(arg));
+                break;
             default:
                 assert(MP_PARSE_NODE_LEAF_KIND(pn) == MP_PARSE_NODE_TOKEN);
-                printf("tok(%u)\n", (uint)arg); break;
+                printf("tok(%u)\n", (uint)arg);
+                break;
         }
     } else {
         // node must be a mp_parse_node_struct_t
-        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t*)pn;
+        mp_parse_node_struct_t *pns = (mp_parse_node_struct_t *)pn;
         if (MP_PARSE_NODE_STRUCT_KIND(pns) == RULE_const_object) {
             #if MICROPY_OBJ_REPR == MICROPY_OBJ_REPR_D
             printf("literal const(%016llx)\n", (uint64_t)pns->nodes[0] | ((uint64_t)pns->nodes[1] << 32));
@@ -521,7 +528,7 @@
             // not interned, make a node holding a pointer to the string/bytes object
             mp_obj_t o = mp_obj_new_str_copy(
                 lex->tok_kind == MP_TOKEN_STRING ? &mp_type_str : &mp_type_bytes,
-                (const byte*)lex->vstr.buf, lex->vstr.len);
+                (const byte *)lex->vstr.buf, lex->vstr.len);
             pn = make_node_const_object(parser, lex->tok_line, o);
         }
     } else {
@@ -634,8 +641,8 @@
             arg0 = mp_binary_op(op, arg0, arg1);
         }
     } else if (rule_id == RULE_shift_expr
-        || rule_id == RULE_arith_expr
-        || rule_id == RULE_term) {
+               || rule_id == RULE_arith_expr
+               || rule_id == RULE_term) {
         // folding for binary ops: << >> + - * @ / % //
         mp_parse_node_t pn = peek_result(parser, num_args - 1);
         if (!mp_parse_node_get_int_maybe(pn, &arg0)) {
@@ -688,14 +695,14 @@
         mp_parse_node_t pn1 = peek_result(parser, 0);
         if (!MP_PARSE_NODE_IS_NULL(pn1)
             && !(MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_augassign)
-            || MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_assign_list))) {
+                 || MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_expr_stmt_assign_list))) {
             // this node is of the form <x> = <y>
             mp_parse_node_t pn0 = peek_result(parser, 1);
             if (MP_PARSE_NODE_IS_ID(pn0)
                 && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_atom_expr_normal)
-                && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t*)pn1)->nodes[0])
-                && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn1)->nodes[0]) == MP_QSTR_const
-                && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t*)pn1)->nodes[1], RULE_trailer_paren)
+                && MP_PARSE_NODE_IS_ID(((mp_parse_node_struct_t *)pn1)->nodes[0])
+                && MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t *)pn1)->nodes[0]) == MP_QSTR_const
+                && MP_PARSE_NODE_IS_STRUCT_KIND(((mp_parse_node_struct_t *)pn1)->nodes[1], RULE_trailer_paren)
                 ) {
                 // code to assign dynamic constants: id = const(value)
 
@@ -703,13 +710,13 @@
                 qstr id = MP_PARSE_NODE_LEAF_ARG(pn0);
 
                 // get the value
-                mp_parse_node_t pn_value = ((mp_parse_node_struct_t*)((mp_parse_node_struct_t*)pn1)->nodes[1])->nodes[0];
+                mp_parse_node_t pn_value = ((mp_parse_node_struct_t *)((mp_parse_node_struct_t *)pn1)->nodes[1])->nodes[0];
                 mp_obj_t value;
                 if (!mp_parse_node_get_int_maybe(pn_value, &value)) {
                     mp_obj_t exc = mp_obj_new_exception_msg(&mp_type_SyntaxError,
                         "constant must be an integer");
                     mp_obj_exception_add_traceback(exc, parser->lexer->source_name,
-                        ((mp_parse_node_struct_t*)pn1)->source_line, MP_QSTRnull);
+                        ((mp_parse_node_struct_t *)pn1)->source_line, MP_QSTRnull);
                     nlr_raise(exc);
                 }
 
@@ -743,16 +750,16 @@
         mp_parse_node_t pn0 = peek_result(parser, 1);
         mp_parse_node_t pn1 = peek_result(parser, 0);
         if (!(MP_PARSE_NODE_IS_ID(pn0)
-            && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) {
+              && MP_PARSE_NODE_IS_STRUCT_KIND(pn1, RULE_trailer_period))) {
             return false;
         }
         // id1.id2
         // look it up in constant table, see if it can be replaced with an integer
-        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t*)pn1;
+        mp_parse_node_struct_t *pns1 = (mp_parse_node_struct_t *)pn1;
         assert(MP_PARSE_NODE_IS_ID(pns1->nodes[0]));
         qstr q_base = MP_PARSE_NODE_LEAF_ARG(pn0);
         qstr q_attr = MP_PARSE_NODE_LEAF_ARG(pns1->nodes[0]);
-        mp_map_elem_t *elem = mp_map_lookup((mp_map_t*)&mp_constants_map, MP_OBJ_NEW_QSTR(q_base), MP_MAP_LOOKUP);
+        mp_map_elem_t *elem = mp_map_lookup((mp_map_t *)&mp_constants_map, MP_OBJ_NEW_QSTR(q_base), MP_MAP_LOOKUP);
         if (elem == NULL) {
             return false;
         }
@@ -845,9 +852,14 @@
     // work out the top-level rule to use, and push it on the stack
     size_t top_level_rule;
     switch (input_kind) {
-        case MP_PARSE_SINGLE_INPUT: top_level_rule = RULE_single_input; break;
-        case MP_PARSE_EVAL_INPUT: top_level_rule = RULE_eval_input; break;
-        default: top_level_rule = RULE_file_input;
+        case MP_PARSE_SINGLE_INPUT:
+            top_level_rule = RULE_single_input;
+            break;
+        case MP_PARSE_EVAL_INPUT:
+            top_level_rule = RULE_eval_input;
+            break;
+        default:
+            top_level_rule = RULE_file_input;
     }
     push_rule(&parser, lex->tok_line, top_level_rule, 0);
 
@@ -856,7 +868,7 @@
     bool backtrack = false;
 
     for (;;) {
-        next_rule:
+    next_rule:
         if (parser.rule_stack_top == 0) {
             break;
         }
@@ -1028,7 +1040,7 @@
                 // n=3 is: item (sep item)* [sep]
                 bool had_trailing_sep;
                 if (backtrack) {
-                    list_backtrack:
+                list_backtrack:
                     had_trailing_sep = false;
                     if (n == 2) {
                         if (i == 1) {
diff --git a/py/parse.h b/py/parse.h
index 9a1a2b4..0963862 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -63,7 +63,7 @@
 #define MP_PARSE_NODE_IS_NULL(pn) ((pn) == MP_PARSE_NODE_NULL)
 #define MP_PARSE_NODE_IS_LEAF(pn) ((pn) & 3)
 #define MP_PARSE_NODE_IS_STRUCT(pn) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0)
-#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t*)(pn)) == (k))
+#define MP_PARSE_NODE_IS_STRUCT_KIND(pn, k) ((pn) != MP_PARSE_NODE_NULL && ((pn) & 3) == 0 && MP_PARSE_NODE_STRUCT_KIND((mp_parse_node_struct_t *)(pn)) == (k))
 
 #define MP_PARSE_NODE_IS_SMALL_INT(pn) (((pn) & 0x1) == MP_PARSE_NODE_SMALL_INT)
 #define MP_PARSE_NODE_IS_ID(pn) (((pn) & 0x0f) == MP_PARSE_NODE_ID)
diff --git a/py/parsenum.c b/py/parsenum.c
index 2b01b72..cdcae80 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -40,7 +40,7 @@
     // if lex!=NULL then the parser called us and we need to convert the
     // exception's type from ValueError to SyntaxError and add traceback info
     if (lex != NULL) {
-        ((mp_obj_base_t*)MP_OBJ_TO_PTR(exc))->type = &mp_type_SyntaxError;
+        ((mp_obj_base_t *)MP_OBJ_TO_PTR(exc))->type = &mp_type_SyntaxError;
         mp_obj_exception_add_traceback(exc, lex->source_name, lex->tok_line, MP_QSTRnull);
     }
     nlr_raise(exc);
@@ -73,7 +73,7 @@
     }
 
     // parse optional base prefix
-    str += mp_parse_num_base((const char*)str, top - str, &base);
+    str += mp_parse_num_base((const char *)str, top - str, &base);
 
     // string should be an integer number
     mp_int_t int_val = 0;
@@ -137,9 +137,9 @@
 overflow:
     // reparse using long int
     {
-        const char *s2 = (const char*)str_val_start;
+        const char *s2 = (const char *)str_val_start;
         ret_val = mp_obj_new_int_from_str_len(&s2, top - str_val_start, neg, base);
-        str = (const byte*)s2;
+        str = (const byte *)s2;
         goto have_ret_val;
     }
 
@@ -171,7 +171,7 @@
 } parse_dec_in_t;
 
 mp_obj_t mp_parse_num_decimal(const char *str, size_t len, bool allow_imag, bool force_complex, mp_lexer_t *lex) {
-#if MICROPY_PY_BUILTINS_FLOAT
+    #if MICROPY_PY_BUILTINS_FLOAT
 
 // DEC_VAL_MAX only needs to be rough and is used to retain precision while not overflowing
 // SMALL_NORMAL_VAL is the smallest power of 10 that is still a normal float
@@ -179,17 +179,17 @@
 //   Note: EXACT_POWER_OF_10 is at least floor(log_5(2^mantissa_length)). Indeed, 10^n = 2^n * 5^n
 //   so we only have to store the 5^n part in the mantissa (the 2^n part will go into the float's
 //   exponent).
-#if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
+    #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
 #define DEC_VAL_MAX 1e20F
 #define SMALL_NORMAL_VAL (1e-37F)
 #define SMALL_NORMAL_EXP (-37)
 #define EXACT_POWER_OF_10 (9)
-#elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
+    #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
 #define DEC_VAL_MAX 1e200
 #define SMALL_NORMAL_VAL (1e-307)
 #define SMALL_NORMAL_EXP (-307)
 #define EXACT_POWER_OF_10 (22)
-#endif
+    #endif
 
     const char *top = str + len;
     mp_float_t dec_val = 0;
@@ -334,17 +334,17 @@
     }
 
     // return the object
-#if MICROPY_PY_BUILTINS_COMPLEX
+    #if MICROPY_PY_BUILTINS_COMPLEX
     if (imag) {
         return mp_obj_new_complex(0, dec_val);
     } else if (force_complex) {
         return mp_obj_new_complex(dec_val, 0);
     }
-#else
+    #else
     if (imag || force_complex) {
         raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "complex values not supported"), lex);
     }
-#endif
+    #endif
     else {
         return mp_obj_new_float(dec_val);
     }
@@ -352,7 +352,7 @@
 value_error:
     raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "invalid syntax for number"), lex);
 
-#else
+    #else
     raise_exc(mp_obj_new_exception_msg(&mp_type_ValueError, "decimal numbers not supported"), lex);
-#endif
+    #endif
 }
diff --git a/py/parsenumbase.c b/py/parsenumbase.c
index ba10591..94523a6 100644
--- a/py/parsenumbase.c
+++ b/py/parsenumbase.c
@@ -31,7 +31,7 @@
 // find real radix base, and strip preceding '0x', '0o' and '0b'
 // puts base in *base, and returns number of bytes to skip the prefix
 size_t mp_parse_num_base(const char *str, size_t len, int *base) {
-    const byte *p = (const byte*)str;
+    const byte *p = (const byte *)str;
     if (len <= 1) {
         goto no_prefix;
     }
@@ -67,5 +67,5 @@
             *base = 10;
         }
     }
-    return p - (const byte*)str;
+    return p - (const byte *)str;
 }
diff --git a/py/persistentcode.c b/py/persistentcode.c
index 7039f9f..19cfb02 100644
--- a/py/persistentcode.c
+++ b/py/persistentcode.c
@@ -135,7 +135,7 @@
     prelude->n_kwonly_args = n_kwonly_args;
     prelude->n_def_pos_args = n_def_pos_args;
     MP_BC_PRELUDE_SIZE_DECODE(*ip);
-    byte *ip_info = (byte*)*ip;
+    byte *ip_info = (byte *)*ip;
     *ip += n_info;
     *ip += n_cell;
     return ip_info;
@@ -160,9 +160,9 @@
 #if MICROPY_EMIT_THUMB
 STATIC void asm_thumb_rewrite_mov(uint8_t *pc, uint16_t val) {
     // high part
-    *(uint16_t*)pc = (*(uint16_t*)pc & 0xfbf0) | (val >> 1 & 0x0400) | (val >> 12);
+    *(uint16_t *)pc = (*(uint16_t *)pc & 0xfbf0) | (val >> 1 & 0x0400) | (val >> 12);
     // low part
-    *(uint16_t*)(pc + 2) = (*(uint16_t*)(pc + 2) & 0x0f00) | (val << 4 & 0x7000) | (val & 0x00ff);
+    *(uint16_t *)(pc + 2) = (*(uint16_t *)(pc + 2) & 0x0f00) | (val << 4 & 0x7000) | (val & 0x00ff);
 
 }
 #endif
@@ -200,10 +200,10 @@
             size_t addr = read_uint(ri->reader, NULL);
             if ((addr & 1) == 0) {
                 // Point to somewhere in text
-                addr_to_adjust = &((uintptr_t*)text)[addr >> 1];
+                addr_to_adjust = &((uintptr_t *)text)[addr >> 1];
             } else {
                 // Point to somewhere in rodata
-                addr_to_adjust = &((uintptr_t*)ri->const_table[1])[addr >> 1];
+                addr_to_adjust = &((uintptr_t *)ri->const_table[1])[addr >> 1];
             }
         }
         op >>= 1;
@@ -227,7 +227,7 @@
             dest = (uintptr_t)&mp_fun_table;
         } else {
             // Destination is an entry in mp_fun_table
-            dest = ((uintptr_t*)&mp_fun_table)[op - 7];
+            dest = ((uintptr_t *)&mp_fun_table)[op - 7];
         }
         while (n--) {
             *addr_to_adjust++ += dest;
@@ -275,7 +275,7 @@
     }
     len >>= 1;
     char *str = m_new(char, len);
-    read_bytes(reader, (byte*)str, len);
+    read_bytes(reader, (byte *)str, len);
     qstr qst = qstr_from_strn(str, len);
     m_del(char, str, len);
     qstr_window_push(qw, qst);
@@ -290,7 +290,7 @@
         size_t len = read_uint(reader, NULL);
         vstr_t vstr;
         vstr_init_len(&vstr, len);
-        read_bytes(reader, (byte*)vstr.buf, len);
+        read_bytes(reader, (byte *)vstr.buf, len);
         if (obj_type == 's' || obj_type == 'b') {
             return mp_obj_new_str_from_vstr(obj_type == 's' ? &mp_type_str : &mp_type_bytes, &vstr);
         } else if (obj_type == 'i') {
@@ -304,9 +304,11 @@
 
 STATIC void load_prelude_qstrs(mp_reader_t *reader, qstr_window_t *qw, byte *ip) {
     qstr simple_name = load_qstr(reader, qw);
-    ip[0] = simple_name; ip[1] = simple_name >> 8;
+    ip[0] = simple_name;
+    ip[1] = simple_name >> 8;
     qstr source_file = load_qstr(reader, qw);
-    ip[2] = source_file; ip[3] = source_file >> 8;
+    ip[2] = source_file;
+    ip[3] = source_file >> 8;
 }
 
 STATIC void load_prelude(mp_reader_t *reader, qstr_window_t *qw, byte **ip, bytecode_prelude_t *prelude) {
@@ -316,7 +318,7 @@
     read_uint(reader, &ip_read);                    // read in n_info/n_cell (is effectively a var-uint)
 
     // Prelude header has been read into *ip, now decode and extract values from it
-    extract_prelude((const byte**)ip, prelude);
+    extract_prelude((const byte **)ip, prelude);
 
     // Load qstrs in prelude
     load_prelude_qstrs(reader, qw, ip_read);
@@ -382,7 +384,7 @@
     } else {
         // Allocate memory for native data and load it
         size_t fun_alloc;
-        MP_PLAT_ALLOC_EXEC(fun_data_len, (void**)&fun_data, &fun_alloc);
+        MP_PLAT_ALLOC_EXEC(fun_data_len, (void **)&fun_data, &fun_alloc);
         read_bytes(reader, fun_data, fun_data_len);
 
         if (kind == MP_CODE_NATIVE_PY || kind == MP_CODE_NATIVE_VIPER) {
@@ -398,7 +400,7 @@
                     dest[1] = (qst >> 8) & 0xff;
                 } else if ((off & 3) == 3) {
                     // Generic, aligned qstr-object link
-                    *(mp_obj_t*)dest = MP_OBJ_NEW_QSTR(qst);
+                    *(mp_obj_t *)dest = MP_OBJ_NEW_QSTR(qst);
                 } else {
                     // Architecture-specific link
                     arch_link_qstr(dest, (off & 3) == 2, qst);
@@ -578,7 +580,7 @@
 #include "py/objstr.h"
 
 STATIC void mp_print_bytes(mp_print_t *print, const byte *data, size_t len) {
-    print->print_strn(print->data, (const char*)data, len);
+    print->print_strn(print->data, (const char *)data, len);
 }
 
 #define BYTES_FOR_INT ((BYTES_PER_WORD * 8 + 6) / 7)
@@ -590,7 +592,7 @@
     for (; n != 0; n >>= 7) {
         *--p = 0x80 | (n & 0x7f);
     }
-    print->print_strn(print->data, (char*)p, buf + sizeof(buf) - p);
+    print->print_strn(print->data, (char *)p, buf + sizeof(buf) - p);
 }
 
 STATIC void save_qstr(mp_print_t *print, qstr_window_t *qw, qstr qst) {
@@ -624,7 +626,7 @@
         const char *str = mp_obj_str_get_data(o, &len);
         mp_print_bytes(print, &obj_type, 1);
         mp_print_uint(print, len);
-        mp_print_bytes(print, (const byte*)str, len);
+        mp_print_bytes(print, (const byte *)str, len);
     } else if (MP_OBJ_TO_PTR(o) == &mp_const_ellipsis_obj) {
         byte obj_type = 'e';
         mp_print_bytes(print, &obj_type, 1);
@@ -648,7 +650,7 @@
         mp_obj_print_helper(&pr, o, PRINT_REPR);
         mp_print_bytes(print, &obj_type, 1);
         mp_print_uint(print, vstr.len);
-        mp_print_bytes(print, (const byte*)vstr.buf, vstr.len);
+        mp_print_bytes(print, (const byte *)vstr.buf, vstr.len);
         vstr_clear(&vstr);
     }
 }
@@ -686,13 +688,13 @@
         const byte *ip_info = extract_prelude(&ip, &prelude);
 
         // Save prelude
-        mp_print_bytes(print, rc->fun_data, ip_info - (const byte*)rc->fun_data);
+        mp_print_bytes(print, rc->fun_data, ip_info - (const byte *)rc->fun_data);
         save_prelude_qstrs(print, qstr_window, ip_info);
         ip_info += 4;
         mp_print_bytes(print, ip_info, ip - ip_info);
 
         // Save bytecode
-        const byte *ip_top = (const byte*)rc->fun_data + rc->fun_data_len;
+        const byte *ip_top = (const byte *)rc->fun_data + rc->fun_data_len;
         save_bytecode(print, qstr_window, ip, ip_top);
     #if MICROPY_EMIT_MACHINE_CODE
     } else {
@@ -713,7 +715,7 @@
             mp_print_uint(print, rc->prelude_offset);
 
             // Extract prelude and save qstrs in prelude
-            const byte *ip = (const byte*)rc->fun_data + rc->prelude_offset;
+            const byte *ip = (const byte *)rc->fun_data + rc->prelude_offset;
             const byte *ip_info = extract_prelude(&ip, &prelude);
             save_prelude_qstrs(print, qstr_window, ip_info);
         } else {
@@ -755,7 +757,7 @@
             save_obj(print, (mp_obj_t)*const_table++);
         }
         for (size_t i = 0; i < rc->n_raw_code; ++i) {
-            save_raw_code(print, (mp_raw_code_t*)(uintptr_t)*const_table++, qstr_window);
+            save_raw_code(print, (mp_raw_code_t *)(uintptr_t)*const_table++, qstr_window);
         }
     }
 }
@@ -774,7 +776,7 @@
         + rc->n_obj;
 
     for (size_t i = 0; i < rc->n_raw_code; ++i) {
-        if (mp_raw_code_has_native((mp_raw_code_t*)(uintptr_t)*const_table++)) {
+        if (mp_raw_code_has_native((mp_raw_code_t *)(uintptr_t)*const_table++)) {
             return true;
         }
     }
@@ -832,7 +834,7 @@
     MP_THREAD_GIL_EXIT();
     int fd = open(filename, O_WRONLY | O_CREAT | O_TRUNC, 0644);
     MP_THREAD_GIL_ENTER();
-    mp_print_t fd_print = {(void*)(intptr_t)fd, fd_print_strn};
+    mp_print_t fd_print = {(void *)(intptr_t)fd, fd_print_strn};
     mp_raw_code_save(rc, &fd_print);
     MP_THREAD_GIL_EXIT();
     close(fd);
diff --git a/py/profile.c b/py/profile.c
index 72726cd..863b006 100644
--- a/py/profile.c
+++ b/py/profile.c
@@ -73,18 +73,18 @@
         o,
         prelude->qstr_source_file,
         rc->line_of_definition
-    );
+        );
 }
 
-STATIC mp_obj_tuple_t* code_consts(const mp_raw_code_t *rc) {
+STATIC mp_obj_tuple_t *code_consts(const mp_raw_code_t *rc) {
     const mp_bytecode_prelude_t *prelude = &rc->prelude;
     int start = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj;
-    int stop  = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj + rc->n_raw_code;
+    int stop = prelude->n_pos_args + prelude->n_kwonly_args + rc->n_obj + rc->n_raw_code;
     mp_obj_tuple_t *consts = MP_OBJ_TO_PTR(mp_obj_new_tuple(stop - start + 1, NULL));
 
     size_t const_no = 0;
     for (int i = start; i < stop; ++i) {
-        mp_obj_t code = mp_obj_new_code((const mp_raw_code_t*)MP_OBJ_TO_PTR(rc->const_table[i]));
+        mp_obj_t code = mp_obj_new_code((const mp_raw_code_t *)MP_OBJ_TO_PTR(rc->const_table[i]));
         if (code == MP_OBJ_NULL) {
             m_malloc_fail(sizeof(mp_obj_code_t));
         }
@@ -103,7 +103,7 @@
     uint last_lineno = mp_prof_bytecode_lineno(rc, start);
     uint lasti = 0;
 
-    const uint buffer_chunk_size = (stop-start) >> 2; // heuristic magic
+    const uint buffer_chunk_size = (stop - start) >> 2; // heuristic magic
     uint buffer_size = buffer_chunk_size;
     byte *buffer = m_new(byte, buffer_size);
     uint buffer_index = 0;
@@ -141,12 +141,12 @@
     mp_obj_code_t *o = MP_OBJ_TO_PTR(self_in);
     const mp_raw_code_t *rc = o->rc;
     const mp_bytecode_prelude_t *prelude = &rc->prelude;
-    switch(attr) {
+    switch (attr) {
         case MP_QSTR_co_code:
             dest[0] = mp_obj_new_bytes(
-                (void*)prelude->opcodes,
-                rc->fun_data_len - (prelude->opcodes - (const byte*)rc->fun_data)
-            );
+                (void *)prelude->opcodes,
+                rc->fun_data_len - (prelude->opcodes - (const byte *)rc->fun_data)
+                );
             break;
         case MP_QSTR_co_consts:
             dest[0] = MP_OBJ_FROM_PTR(code_consts(rc));
@@ -165,7 +165,7 @@
             break;
         case MP_QSTR_co_lnotab:
             if (!o->lnotab) {
-                 o->lnotab = raw_code_lnotab(rc);
+                o->lnotab = raw_code_lnotab(rc);
             }
             dest[0] = o->lnotab;
             break;
@@ -207,7 +207,7 @@
         prelude->qstr_source_file,
         frame->lineno,
         prelude->qstr_block_name
-    );
+        );
 }
 
 STATIC void frame_attr(mp_obj_t self_in, qstr attr, mp_obj_t *dest) {
@@ -218,7 +218,7 @@
 
     mp_obj_frame_t *o = MP_OBJ_TO_PTR(self_in);
 
-    switch(attr) {
+    switch (attr) {
         case MP_QSTR_f_back:
             dest[0] = mp_const_none;
             if (o->code_state->prev_state) {
@@ -282,7 +282,7 @@
 // Trace logic
 
 typedef struct {
-    struct _mp_obj_frame_t * frame;
+    struct _mp_obj_frame_t *frame;
     mp_obj_t event;
     mp_obj_t arg;
 } prof_callback_args_t;
@@ -340,7 +340,7 @@
     }
 
     mp_obj_t top;
-    prof_callback_args_t _args, *args=&_args;
+    prof_callback_args_t _args, *args = &_args;
     args->frame = code_state->frame;
 
     // SETTRACE event CALL
@@ -388,7 +388,7 @@
     mp_obj_t top = mp_const_none;
     mp_obj_t callback = code_state->frame->callback;
 
-    prof_callback_args_t _args, *args=&_args;
+    prof_callback_args_t _args, *args = &_args;
     args->frame = code_state->frame;
     args->event = mp_const_none;
     args->arg = mp_const_none;
@@ -444,10 +444,10 @@
 #include "runtime0.h"
 
 #define DECODE_UINT { \
-    unum = 0; \
-    do { \
-        unum = (unum << 7) + (*ip & 0x7f); \
-    } while ((*ip++ & 0x80) != 0); \
+        unum = 0; \
+        do { \
+            unum = (unum << 7) + (*ip & 0x7f); \
+        } while ((*ip++ & 0x80) != 0); \
 }
 #define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
 #define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
@@ -457,7 +457,7 @@
     ip += 2;
 #define DECODE_PTR \
     DECODE_UINT; \
-    ptr = (const byte*)const_table[unum]
+    ptr = (const byte *)const_table[unum]
 #define DECODE_OBJ \
     DECODE_UINT; \
     obj = (mp_obj_t)const_table[unum]
@@ -471,13 +471,13 @@
 
 STATIC const byte *mp_prof_opcode_decode(const byte *ip, const mp_uint_t *const_table, mp_dis_instruction_t *instruction) {
     mp_uint_t unum;
-    const byte* ptr;
+    const byte *ptr;
     mp_obj_t obj;
     qstr qst;
 
     instruction->qstr_opname = MP_QSTR_;
     instruction->arg = 0;
-    instruction->argobj= mp_const_none;
+    instruction->argobj = mp_const_none;
     instruction->argobjex_cache = mp_const_none;
 
     switch (*ip++) {
@@ -511,14 +511,14 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_CONST_STRING;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_LOAD_CONST_OBJ:
             DECODE_OBJ;
             instruction->qstr_opname = MP_QSTR_LOAD_CONST_OBJ;
             instruction->arg = unum;
-            instruction->argobj= obj;
+            instruction->argobj = obj;
             break;
 
         case MP_BC_LOAD_NULL:
@@ -541,7 +541,7 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_NAME;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
                 instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
             }
@@ -551,7 +551,7 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_GLOBAL;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
                 instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
             }
@@ -561,7 +561,7 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_ATTR;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
                 instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
             }
@@ -571,14 +571,14 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_METHOD;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_LOAD_SUPER_METHOD:
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_LOAD_SUPER_METHOD;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_LOAD_BUILD_CLASS:
@@ -605,21 +605,21 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_STORE_NAME;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_STORE_GLOBAL:
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_STORE_GLOBAL;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_STORE_ATTR:
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_STORE_ATTR;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             if (MICROPY_OPT_CACHE_MAP_LOOKUP_IN_BYTECODE) {
                 instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(*ip++);
             }
@@ -645,14 +645,14 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_DELETE_NAME;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_DELETE_GLOBAL:
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_DELETE_GLOBAL;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_DUP_TOP:
@@ -813,14 +813,14 @@
             DECODE_PTR;
             instruction->qstr_opname = MP_QSTR_MAKE_FUNCTION;
             instruction->arg = unum;
-            instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
+            instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
             break;
 
         case MP_BC_MAKE_FUNCTION_DEFARGS:
             DECODE_PTR;
             instruction->qstr_opname = MP_QSTR_MAKE_FUNCTION_DEFARGS;
             instruction->arg = unum;
-            instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
+            instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
             break;
 
         case MP_BC_MAKE_CLOSURE: {
@@ -828,7 +828,7 @@
             mp_uint_t n_closed_over = *ip++;
             instruction->qstr_opname = MP_QSTR_MAKE_CLOSURE;
             instruction->arg = unum;
-            instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
+            instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
             instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(n_closed_over);
             break;
         }
@@ -838,7 +838,7 @@
             mp_uint_t n_closed_over = *ip++;
             instruction->qstr_opname = MP_QSTR_MAKE_CLOSURE_DEFARGS;
             instruction->arg = unum;
-            instruction->argobj= mp_obj_new_int_from_ull((uint64_t)ptr);
+            instruction->argobj = mp_obj_new_int_from_ull((uint64_t)ptr);
             instruction->argobjex_cache = MP_OBJ_NEW_SMALL_INT(n_closed_over);
             break;
         }
@@ -899,14 +899,14 @@
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_IMPORT_NAME;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_IMPORT_FROM:
             DECODE_QSTR;
             instruction->qstr_opname = MP_QSTR_IMPORT_FROM;
             instruction->arg = qst;
-            instruction->argobj= MP_OBJ_NEW_QSTR(qst);
+            instruction->argobj = MP_OBJ_NEW_QSTR(qst);
             break;
 
         case MP_BC_IMPORT_STAR:
@@ -931,7 +931,7 @@
                 instruction->qstr_opname = MP_QSTR_BINARY_OP;
                 instruction->arg = op;
             } else {
-                mp_printf(&mp_plat_print, "code %p, opcode 0x%02x not implemented\n", ip-1, ip[-1]);
+                mp_printf(&mp_plat_print, "code %p, opcode 0x%02x not implemented\n", ip - 1, ip[-1]);
                 assert(0);
                 return ip;
             }
@@ -941,7 +941,7 @@
     return ip;
 }
 
-void mp_prof_print_instr(const byte* ip, mp_code_state_t *code_state) {
+void mp_prof_print_instr(const byte *ip, mp_code_state_t *code_state) {
     mp_dis_instruction_t _instruction, *instruction = &_instruction;
     mp_prof_opcode_decode(ip, code_state->fun_bc->rc->const_table, instruction);
     const mp_raw_code_t *rc = code_state->fun_bc->rc;
@@ -958,7 +958,7 @@
             prelude->qstr_block_name,
             offset,
             mp_prof_bytecode_lineno(rc, offset)
-        );
+            );
     }
 
     /* bytecode */ if (0) {
diff --git a/py/profile.h b/py/profile.h
index 0293e26..64e207d 100644
--- a/py/profile.h
+++ b/py/profile.h
@@ -69,7 +69,7 @@
 // to be included in production/release builds.
 #define MICROPY_PROF_INSTR_DEBUG_PRINT_ENABLE 0
 #if MICROPY_PROF_INSTR_DEBUG_PRINT_ENABLE
-void mp_prof_print_instr(const byte* ip, mp_code_state_t *code_state);
+void mp_prof_print_instr(const byte *ip, mp_code_state_t *code_state);
 #define MP_PROF_INSTR_DEBUG_PRINT(current_ip) mp_prof_print_instr((current_ip), code_state)
 #else
 #define MP_PROF_INSTR_DEBUG_PRINT(current_ip)
diff --git a/py/pystack.c b/py/pystack.c
index 552e59d..f7323fd 100644
--- a/py/pystack.c
+++ b/py/pystack.c
@@ -49,7 +49,7 @@
     void *ptr = MP_STATE_THREAD(pystack_cur);
     MP_STATE_THREAD(pystack_cur) += n_bytes;
     #if MP_PYSTACK_DEBUG
-    *(size_t*)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN) = n_bytes;
+    *(size_t *)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN) = n_bytes;
     #endif
     return ptr;
 }
diff --git a/py/pystack.h b/py/pystack.h
index 82ac374..ea8fddc 100644
--- a/py/pystack.h
+++ b/py/pystack.h
@@ -41,21 +41,21 @@
 // pointer to the block that was allocated first and it and all subsequently
 // allocated blocks will be freed.
 static inline void mp_pystack_free(void *ptr) {
-    assert((uint8_t*)ptr >= MP_STATE_THREAD(pystack_start));
-    assert((uint8_t*)ptr <= MP_STATE_THREAD(pystack_cur));
+    assert((uint8_t *)ptr >= MP_STATE_THREAD(pystack_start));
+    assert((uint8_t *)ptr <= MP_STATE_THREAD(pystack_cur));
     #if MP_PYSTACK_DEBUG
-    size_t n_bytes_to_free = MP_STATE_THREAD(pystack_cur) - (uint8_t*)ptr;
-    size_t n_bytes = *(size_t*)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN);
+    size_t n_bytes_to_free = MP_STATE_THREAD(pystack_cur) - (uint8_t *)ptr;
+    size_t n_bytes = *(size_t *)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN);
     while (n_bytes < n_bytes_to_free) {
-        n_bytes += *(size_t*)(MP_STATE_THREAD(pystack_cur) - n_bytes - MICROPY_PYSTACK_ALIGN);
+        n_bytes += *(size_t *)(MP_STATE_THREAD(pystack_cur) - n_bytes - MICROPY_PYSTACK_ALIGN);
     }
     if (n_bytes != n_bytes_to_free) {
         mp_printf(&mp_plat_print, "mp_pystack_free() failed: %u != %u\n", (uint)n_bytes_to_free,
-            (uint)*(size_t*)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN));
+            (uint)*(size_t *)(MP_STATE_THREAD(pystack_cur) - MICROPY_PYSTACK_ALIGN));
         assert(0);
     }
     #endif
-    MP_STATE_THREAD(pystack_cur) = (uint8_t*)ptr;
+    MP_STATE_THREAD(pystack_cur) = (uint8_t *)ptr;
 }
 
 static inline void mp_pystack_realloc(void *ptr, size_t n_bytes) {
diff --git a/py/qstr.c b/py/qstr.c
index 940d09e..c3d78bf 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -106,11 +106,11 @@
     MICROPY_ALLOC_QSTR_ENTRIES_INIT,
     MP_QSTRnumber_of,   // corresponds to number of strings in array just below
     {
-#ifndef NO_QSTR
+        #ifndef NO_QSTR
 #define QDEF(id, str) str,
-#include "genhdr/qstrdefs.generated.h"
+        #include "genhdr/qstrdefs.generated.h"
 #undef QDEF
-#endif
+        #endif
     },
 };
 
@@ -122,7 +122,7 @@
 #endif
 
 void qstr_init(void) {
-    MP_STATE_VM(last_pool) = (qstr_pool_t*)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
+    MP_STATE_VM(last_pool) = (qstr_pool_t *)&CONST_POOL; // we won't modify the const_pool since it has no allocated room left
     MP_STATE_VM(qstr_last_chunk) = NULL;
 
     #if MICROPY_PY_THREAD && !MICROPY_PY_THREAD_GIL
@@ -151,7 +151,7 @@
         // Put a lower bound on the allocation size in case the extra qstr pool has few entries
         new_alloc = MAX(MICROPY_ALLOC_QSTR_ENTRIES_INIT, new_alloc);
         #endif
-        qstr_pool_t *pool = m_new_obj_var_maybe(qstr_pool_t, const char*, new_alloc);
+        qstr_pool_t *pool = m_new_obj_var_maybe(qstr_pool_t, const char *, new_alloc);
         if (pool == NULL) {
             QSTR_EXIT();
             m_malloc_fail(new_alloc);
@@ -173,7 +173,7 @@
 
 qstr qstr_find_strn(const char *str, size_t str_len) {
     // work out hash of str
-    mp_uint_t str_hash = qstr_compute_hash((const byte*)str, str_len);
+    mp_uint_t str_hash = qstr_compute_hash((const byte *)str, str_len);
 
     // search pools for the data
     for (qstr_pool_t *pool = MP_STATE_VM(last_pool); pool != NULL; pool = pool->prev) {
@@ -245,7 +245,7 @@
         MP_STATE_VM(qstr_last_used) += n_bytes;
 
         // store the interned strings' data
-        mp_uint_t hash = qstr_compute_hash((const byte*)str, len);
+        mp_uint_t hash = qstr_compute_hash((const byte *)str, len);
         Q_SET_HASH(q_ptr, hash);
         Q_SET_LENGTH(q_ptr, len);
         memcpy(q_ptr + MICROPY_QSTR_BYTES_IN_HASH + MICROPY_QSTR_BYTES_IN_LEN, str, len);
@@ -268,7 +268,7 @@
 
 const char *qstr_str(qstr q) {
     const byte *qd = find_qstr(q);
-    return (const char*)Q_GET_DATA(qd);
+    return (const char *)Q_GET_DATA(qd);
 }
 
 const byte *qstr_data(qstr q, size_t *len) {
diff --git a/py/qstr.h b/py/qstr.h
index 8153ef2..7dd3024 100644
--- a/py/qstr.h
+++ b/py/qstr.h
@@ -37,11 +37,11 @@
 
 // first entry in enum will be MP_QSTRnull=0, which indicates invalid/no qstr
 enum {
-#ifndef NO_QSTR
+    #ifndef NO_QSTR
 #define QDEF(id, str) id,
-#include "genhdr/qstrdefs.generated.h"
+    #include "genhdr/qstrdefs.generated.h"
 #undef QDEF
-#endif
+    #endif
     MP_QSTRnumber_of, // no underscore so it can't clash with any of the above
 };
 
diff --git a/py/reader.c b/py/reader.c
index d99dfc5..d68406b 100644
--- a/py/reader.c
+++ b/py/reader.c
@@ -40,7 +40,7 @@
 } mp_reader_mem_t;
 
 STATIC mp_uint_t mp_reader_mem_readbyte(void *data) {
-    mp_reader_mem_t *reader = (mp_reader_mem_t*)data;
+    mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
     if (reader->cur < reader->end) {
         return *reader->cur++;
     } else {
@@ -49,9 +49,9 @@
 }
 
 STATIC void mp_reader_mem_close(void *data) {
-    mp_reader_mem_t *reader = (mp_reader_mem_t*)data;
+    mp_reader_mem_t *reader = (mp_reader_mem_t *)data;
     if (reader->free_len > 0) {
-        m_del(char, (char*)reader->beg, reader->free_len);
+        m_del(char, (char *)reader->beg, reader->free_len);
     }
     m_del_obj(mp_reader_mem_t, reader);
 }
@@ -82,7 +82,7 @@
 } mp_reader_posix_t;
 
 STATIC mp_uint_t mp_reader_posix_readbyte(void *data) {
-    mp_reader_posix_t *reader = (mp_reader_posix_t*)data;
+    mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
     if (reader->pos >= reader->len) {
         if (reader->len == 0) {
             return MP_READER_EOF;
@@ -102,7 +102,7 @@
 }
 
 STATIC void mp_reader_posix_close(void *data) {
-    mp_reader_posix_t *reader = (mp_reader_posix_t*)data;
+    mp_reader_posix_t *reader = (mp_reader_posix_t *)data;
     if (reader->close_fd) {
         MP_THREAD_GIL_EXIT();
         close(reader->fd);
diff --git a/py/repl.c b/py/repl.c
index 9389b34..c758fc0 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -50,7 +50,7 @@
 
     // check if input starts with a certain keyword
     bool starts_with_compound_keyword =
-           input[0] == '@'
+        input[0] == '@'
         || str_startswith_word(input, "if")
         || str_startswith_word(input, "while")
         || str_startswith_word(input, "for")
@@ -61,7 +61,7 @@
         #if MICROPY_PY_ASYNC_AWAIT
         || str_startswith_word(input, "async")
         #endif
-        ;
+    ;
 
     // check for unmatched open bracket, quote or escape quote
     #define Q_NONE (0)
@@ -95,13 +95,26 @@
             }
         } else if (in_quote == Q_NONE) {
             switch (*i) {
-                case '(': n_paren += 1; break;
-                case ')': n_paren -= 1; break;
-                case '[': n_brack += 1; break;
-                case ']': n_brack -= 1; break;
-                case '{': n_brace += 1; break;
-                case '}': n_brace -= 1; break;
-                default: break;
+                case '(':
+                    n_paren += 1;
+                    break;
+                case ')':
+                    n_paren -= 1;
+                    break;
+                case '[':
+                    n_brack += 1;
+                    break;
+                case ']':
+                    n_brack -= 1;
+                    break;
+                case '{':
+                    n_brace += 1;
+                    break;
+                case '}':
+                    n_brace -= 1;
+                    break;
+                default:
+                    break;
             }
         }
     }
@@ -183,7 +196,7 @@
             qstr q_first = 0, q_last = 0;
             for (qstr q = MP_QSTR_ + 1; q < nqstr; ++q) {
                 size_t d_len;
-                const char *d_str = (const char*)qstr_data(q, &d_len);
+                const char *d_str = (const char *)qstr_data(q, &d_len);
                 if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
                     mp_load_method_protected(obj, q, dest, true);
                     if (dest[0] != MP_OBJ_NULL) {
@@ -237,7 +250,7 @@
             int line_len = MAX_LINE_LEN; // force a newline for first word
             for (qstr q = q_first; q <= q_last; ++q) {
                 size_t d_len;
-                const char *d_str = (const char*)qstr_data(q, &d_len);
+                const char *d_str = (const char *)qstr_data(q, &d_len);
                 if (s_len <= d_len && strncmp(s_start, d_str, s_len) == 0) {
                     mp_load_method_protected(obj, q, dest, true);
                     if (dest[0] != MP_OBJ_NULL) {
diff --git a/py/ringbuf.h b/py/ringbuf.h
index 8d4ed16..4d316d9 100644
--- a/py/ringbuf.h
+++ b/py/ringbuf.h
@@ -42,11 +42,11 @@
 
 // Dynamic initialization. This needs to become findable as a root pointer!
 #define ringbuf_alloc(r, sz) \
-{ \
-    (r)->buf = m_new(uint8_t, sz); \
-    (r)->size = sz; \
-    (r)->iget = (r)->iput = 0; \
-}
+    { \
+        (r)->buf = m_new(uint8_t, sz); \
+        (r)->size = sz; \
+        (r)->iget = (r)->iput = 0; \
+    }
 
 static inline int ringbuf_get(ringbuf_t *r) {
     if (r->iget == r->iput) {
diff --git a/py/runtime.c b/py/runtime.c
index 906d07b..88b89c6 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -55,7 +55,7 @@
 
 const mp_obj_module_t mp_module___main__ = {
     .base = { &mp_type_module },
-    .globals = (mp_obj_dict_t*)&MP_STATE_VM(dict_main),
+    .globals = (mp_obj_dict_t *)&MP_STATE_VM(dict_main),
 };
 
 void mp_init(void) {
@@ -69,9 +69,9 @@
     MP_STATE_VM(sched_len) = 0;
     #endif
 
-#if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
+    #if MICROPY_ENABLE_EMERGENCY_EXCEPTION_BUF
     mp_init_emergency_exception_buf();
-#endif
+    #endif
 
     #if MICROPY_KBD_EXCEPTION
     // initialise the exception object for raising KeyboardInterrupt
@@ -79,7 +79,7 @@
     MP_STATE_VM(mp_kbd_exception).traceback_alloc = 0;
     MP_STATE_VM(mp_kbd_exception).traceback_len = 0;
     MP_STATE_VM(mp_kbd_exception).traceback_data = NULL;
-    MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t*)&mp_const_empty_tuple_obj;
+    MP_STATE_VM(mp_kbd_exception).args = (mp_obj_tuple_t *)&mp_const_empty_tuple_obj;
     #endif
 
     #if MICROPY_ENABLE_COMPILER
@@ -183,7 +183,7 @@
             }
         }
         #endif
-        elem = mp_map_lookup((mp_map_t*)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
+        elem = mp_map_lookup((mp_map_t *)&mp_module_builtins_globals.map, MP_OBJ_NEW_QSTR(qst), MP_MAP_LOOKUP);
         if (elem == NULL) {
             if (MICROPY_ERROR_REPORTING == MICROPY_ERROR_REPORTING_TERSE) {
                 mp_raise_msg(&mp_type_NameError, "name not defined");
@@ -367,11 +367,17 @@
             //      <<      checked explicitly
             switch (op) {
                 case MP_BINARY_OP_OR:
-                case MP_BINARY_OP_INPLACE_OR: lhs_val |= rhs_val; break;
+                case MP_BINARY_OP_INPLACE_OR:
+                    lhs_val |= rhs_val;
+                    break;
                 case MP_BINARY_OP_XOR:
-                case MP_BINARY_OP_INPLACE_XOR: lhs_val ^= rhs_val; break;
+                case MP_BINARY_OP_INPLACE_XOR:
+                    lhs_val ^= rhs_val;
+                    break;
                 case MP_BINARY_OP_AND:
-                case MP_BINARY_OP_INPLACE_AND: lhs_val &= rhs_val; break;
+                case MP_BINARY_OP_INPLACE_AND:
+                    lhs_val &= rhs_val;
+                    break;
                 case MP_BINARY_OP_LSHIFT:
                 case MP_BINARY_OP_INPLACE_LSHIFT: {
                     if (rhs_val < 0) {
@@ -403,9 +409,13 @@
                     }
                     break;
                 case MP_BINARY_OP_ADD:
-                case MP_BINARY_OP_INPLACE_ADD: lhs_val += rhs_val; break;
+                case MP_BINARY_OP_INPLACE_ADD:
+                    lhs_val += rhs_val;
+                    break;
                 case MP_BINARY_OP_SUBTRACT:
-                case MP_BINARY_OP_INPLACE_SUBTRACT: lhs_val -= rhs_val; break;
+                case MP_BINARY_OP_INPLACE_SUBTRACT:
+                    lhs_val -= rhs_val;
+                    break;
                 case MP_BINARY_OP_MULTIPLY:
                 case MP_BINARY_OP_INPLACE_MULTIPLY: {
 
@@ -505,10 +515,14 @@
                     return MP_OBJ_FROM_PTR(tuple);
                 }
 
-                case MP_BINARY_OP_LESS: return mp_obj_new_bool(lhs_val < rhs_val);
-                case MP_BINARY_OP_MORE: return mp_obj_new_bool(lhs_val > rhs_val);
-                case MP_BINARY_OP_LESS_EQUAL: return mp_obj_new_bool(lhs_val <= rhs_val);
-                case MP_BINARY_OP_MORE_EQUAL: return mp_obj_new_bool(lhs_val >= rhs_val);
+                case MP_BINARY_OP_LESS:
+                    return mp_obj_new_bool(lhs_val < rhs_val);
+                case MP_BINARY_OP_MORE:
+                    return mp_obj_new_bool(lhs_val > rhs_val);
+                case MP_BINARY_OP_LESS_EQUAL:
+                    return mp_obj_new_bool(lhs_val <= rhs_val);
+                case MP_BINARY_OP_MORE_EQUAL:
+                    return mp_obj_new_bool(lhs_val >= rhs_val);
 
                 default:
                     goto unsupported_op;
@@ -519,7 +533,7 @@
             } else {
                 return mp_obj_new_int_from_ll(lhs_val);
             }
-#if MICROPY_PY_BUILTINS_FLOAT
+        #if MICROPY_PY_BUILTINS_FLOAT
         } else if (mp_obj_is_float(rhs)) {
             mp_obj_t res = mp_obj_float_binary_op(op, lhs_val, rhs);
             if (res == MP_OBJ_NULL) {
@@ -527,8 +541,8 @@
             } else {
                 return res;
             }
-#endif
-#if MICROPY_PY_BUILTINS_COMPLEX
+        #endif
+        #if MICROPY_PY_BUILTINS_COMPLEX
         } else if (mp_obj_is_type(rhs, &mp_type_complex)) {
             mp_obj_t res = mp_obj_complex_binary_op(op, lhs_val, 0, rhs);
             if (res == MP_OBJ_NULL) {
@@ -536,7 +550,7 @@
             } else {
                 return res;
             }
-#endif
+        #endif
         }
     }
 
@@ -559,7 +573,7 @@
         }
     }
 
-#if MICROPY_PY_REVERSE_SPECIAL_METHODS
+    #if MICROPY_PY_REVERSE_SPECIAL_METHODS
     if (op >= MP_BINARY_OP_OR && op <= MP_BINARY_OP_POWER) {
         mp_obj_t t = rhs;
         rhs = lhs;
@@ -573,7 +587,7 @@
         lhs = t;
         op -= MP_BINARY_OP_REVERSE_OR - MP_BINARY_OP_OR;
     }
-#endif
+    #endif
 
     if (op == MP_BINARY_OP_CONTAINS) {
         // If type didn't support containment then explicitly walk the iterator.
@@ -1000,7 +1014,7 @@
 void mp_convert_member_lookup(mp_obj_t self, const mp_obj_type_t *type, mp_obj_t member, mp_obj_t *dest) {
     if (mp_obj_is_type(member, &mp_type_staticmethod)) {
         // return just the function
-        dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun;
+        dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun;
     } else if (mp_obj_is_type(member, &mp_type_classmethod)) {
         // return a bound method, with self being the type of this object
         // this type should be the type of the original instance, not the base
@@ -1008,18 +1022,18 @@
         if (self != MP_OBJ_NULL) {
             type = mp_obj_get_type(self);
         }
-        dest[0] = ((mp_obj_static_class_method_t*)MP_OBJ_TO_PTR(member))->fun;
+        dest[0] = ((mp_obj_static_class_method_t *)MP_OBJ_TO_PTR(member))->fun;
         dest[1] = MP_OBJ_FROM_PTR(type);
     } else if (mp_obj_is_type(member, &mp_type_type)) {
         // Don't try to bind types (even though they're callable)
         dest[0] = member;
     } else if (mp_obj_is_fun(member)
-        || (mp_obj_is_obj(member)
-            && (((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_closure
-                || ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_generator))) {
+               || (mp_obj_is_obj(member)
+                   && (((mp_obj_base_t *)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_closure
+                       || ((mp_obj_base_t *)MP_OBJ_TO_PTR(member))->type->name == MP_QSTR_generator))) {
         // only functions, closures and generators objects can be bound to self
         #if MICROPY_BUILTIN_METHOD_CHECK_SELF_ARG
-        const mp_obj_type_t *m_type = ((mp_obj_base_t*)MP_OBJ_TO_PTR(member))->type;
+        const mp_obj_type_t *m_type = ((mp_obj_base_t *)MP_OBJ_TO_PTR(member))->type;
         if (self == MP_OBJ_NULL
             && (m_type == &mp_type_fun_builtin_0
                 || m_type == &mp_type_fun_builtin_1
@@ -1098,7 +1112,7 @@
             if (mp_obj_is_type(base, &mp_type_type)) {
                 mp_raise_msg_varg(&mp_type_AttributeError,
                     "type object '%q' has no attribute '%q'",
-                    ((mp_obj_type_t*)MP_OBJ_TO_PTR(base))->name, attr);
+                    ((mp_obj_type_t *)MP_OBJ_TO_PTR(base))->name, attr);
             } else {
                 mp_raise_msg_varg(&mp_type_AttributeError,
                     "'%s' object has no attribute '%q'",
@@ -1116,7 +1130,7 @@
         nlr_pop();
     } else {
         if (!catch_all_exc
-            && !mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type),
+            && !mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type),
                 MP_OBJ_FROM_PTR(&mp_type_AttributeError))) {
             // Re-raise the exception
             nlr_raise(MP_OBJ_FROM_PTR(nlr.ret_val));
@@ -1231,7 +1245,7 @@
                 nlr_pop();
                 return ret;
             } else {
-                if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t*)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
+                if (mp_obj_is_subclass_fast(MP_OBJ_FROM_PTR(((mp_obj_base_t *)nlr.ret_val)->type), MP_OBJ_FROM_PTR(&mp_type_StopIteration))) {
                     return MP_OBJ_STOP_ITERATION;
                 } else {
                     nlr_jump(nlr.ret_val);
@@ -1376,7 +1390,7 @@
 
     if (dest[1] != MP_OBJ_NULL) {
         // Hopefully we can't import bound method from an object
-import_error:
+    import_error:
         mp_raise_msg_varg(&mp_type_ImportError, "cannot import name %q", name);
     }
 
diff --git a/py/runtime.h b/py/runtime.h
index 46e0887..85c377f 100644
--- a/py/runtime.h
+++ b/py/runtime.h
@@ -71,7 +71,9 @@
 #if MICROPY_ENABLE_SCHEDULER
 void mp_sched_lock(void);
 void mp_sched_unlock(void);
-static inline unsigned int mp_sched_num_pending(void) { return MP_STATE_VM(sched_len); }
+static inline unsigned int mp_sched_num_pending(void) {
+    return MP_STATE_VM(sched_len);
+}
 bool mp_sched_schedule(mp_obj_t function, mp_obj_t arg);
 #endif
 
@@ -87,10 +89,18 @@
 NORETURN void mp_arg_error_terse_mismatch(void);
 NORETURN void mp_arg_error_unimpl_kw(void);
 
-static inline mp_obj_dict_t *mp_locals_get(void) { return MP_STATE_THREAD(dict_locals); }
-static inline void mp_locals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_locals) = d; }
-static inline mp_obj_dict_t *mp_globals_get(void) { return MP_STATE_THREAD(dict_globals); }
-static inline void mp_globals_set(mp_obj_dict_t *d) { MP_STATE_THREAD(dict_globals) = d; }
+static inline mp_obj_dict_t *mp_locals_get(void) {
+    return MP_STATE_THREAD(dict_locals);
+}
+static inline void mp_locals_set(mp_obj_dict_t *d) {
+    MP_STATE_THREAD(dict_locals) = d;
+}
+static inline mp_obj_dict_t *mp_globals_get(void) {
+    return MP_STATE_THREAD(dict_globals);
+}
+static inline void mp_globals_set(mp_obj_dict_t *d) {
+    MP_STATE_THREAD(dict_globals) = d;
+}
 
 mp_obj_t mp_load_name(qstr qst);
 mp_obj_t mp_load_global(qstr qst);
diff --git a/py/scope.c b/py/scope.c
index d996731..1e45139 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -47,7 +47,7 @@
     scope->source_file = source_file;
     if (kind == SCOPE_FUNCTION || kind == SCOPE_CLASS) {
         assert(MP_PARSE_NODE_IS_STRUCT(pn));
-        scope->simple_name = MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t*)pn)->nodes[0]);
+        scope->simple_name = MP_PARSE_NODE_LEAF_ARG(((mp_parse_node_struct_t *)pn)->nodes[0]);
     } else {
         scope->simple_name = scope_simple_name_table[kind];
     }
diff --git a/py/sequence.c b/py/sequence.c
index 94a9bb9..c9cb041 100644
--- a/py/sequence.c
+++ b/py/sequence.c
@@ -39,7 +39,7 @@
     for (size_t i = 0; i < times; i++) {
         size_t copy_sz = item_sz * len;
         memcpy(dest, items, copy_sz);
-        dest = (char*)dest + copy_sz;
+        dest = (char *)dest + copy_sz;
     }
 }
 
@@ -96,7 +96,7 @@
 
     // Let's deal only with > & >=
     if (op == MP_BINARY_OP_LESS || op == MP_BINARY_OP_LESS_EQUAL) {
-        SWAP(const byte*, data1, data2);
+        SWAP(const byte *, data1, data2);
         SWAP(size_t, len1, len2);
         if (op == MP_BINARY_OP_LESS) {
             op = MP_BINARY_OP_MORE;
@@ -163,7 +163,7 @@
         }
 
         // Otherwise, application of relation op gives the answer
-        return (mp_binary_op(op, items1[i], items2[i]) == mp_const_true);
+        return mp_binary_op(op, items1[i], items2[i]) == mp_const_true;
     }
 
     // If we had tie in the last element...
@@ -208,9 +208,9 @@
 mp_obj_t mp_seq_count_obj(const mp_obj_t *items, size_t len, mp_obj_t value) {
     size_t count = 0;
     for (size_t i = 0; i < len; i++) {
-         if (mp_obj_equal(items[i], value)) {
-              count++;
-         }
+        if (mp_obj_equal(items[i], value)) {
+            count++;
+        }
     }
 
     // Common sense says this cannot overflow small int
diff --git a/py/showbc.c b/py/showbc.c
index d154511..4d6527f 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -36,10 +36,10 @@
 #define printf(...) mp_printf(&mp_plat_print, __VA_ARGS__)
 
 #define DECODE_UINT { \
-    unum = 0; \
-    do { \
-        unum = (unum << 7) + (*ip & 0x7f); \
-    } while ((*ip++ & 0x80) != 0); \
+        unum = 0; \
+        do { \
+            unum = (unum << 7) + (*ip & 0x7f); \
+        } while ((*ip++ & 0x80) != 0); \
 }
 #define DECODE_ULABEL do { unum = (ip[0] | (ip[1] << 8)); ip += 2; } while (0)
 #define DECODE_SLABEL do { unum = (ip[0] | (ip[1] << 8)) - 0x8000; ip += 2; } while (0)
@@ -59,20 +59,20 @@
 #else
 
 #define DECODE_QSTR { \
-    qst = 0; \
-    do { \
-        qst = (qst << 7) + (*ip & 0x7f); \
-    } while ((*ip++ & 0x80) != 0); \
+        qst = 0; \
+        do { \
+            qst = (qst << 7) + (*ip & 0x7f); \
+        } while ((*ip++ & 0x80) != 0); \
 }
 #define DECODE_PTR do { \
-    ip = (byte*)MP_ALIGN(ip, sizeof(void*)); \
-    unum = (uintptr_t)*(void**)ip; \
-    ip += sizeof(void*); \
+        ip = (byte *)MP_ALIGN(ip, sizeof(void *)); \
+        unum = (uintptr_t)*(void **)ip; \
+        ip += sizeof(void *); \
 } while (0)
 #define DECODE_OBJ do { \
-    ip = (byte*)MP_ALIGN(ip, sizeof(mp_obj_t)); \
-    unum = (mp_uint_t)*(mp_obj_t*)ip; \
-    ip += sizeof(mp_obj_t); \
+        ip = (byte *)MP_ALIGN(ip, sizeof(mp_obj_t)); \
+        unum = (mp_uint_t)*(mp_obj_t *)ip; \
+        ip += sizeof(mp_obj_t); \
 } while (0)
 
 #endif
@@ -135,7 +135,7 @@
         mp_int_t bc = 0;
         mp_uint_t source_line = 1;
         printf("  bc=" INT_FMT " line=" UINT_FMT "\n", bc, source_line);
-        for (const byte* ci = code_info; *ci;) {
+        for (const byte *ci = code_info; *ci;) {
             if ((ci[0] & 0x80) == 0) {
                 // 0b0LLBBBBB encoding
                 bc += ci[0] & 0x1f;
@@ -422,12 +422,12 @@
             printf("BUILD_SET " UINT_FMT, unum);
             break;
 
-#if MICROPY_PY_BUILTINS_SLICE
+        #if MICROPY_PY_BUILTINS_SLICE
         case MP_BC_BUILD_SLICE:
             DECODE_UINT;
             printf("BUILD_SLICE " UINT_FMT, unum);
             break;
-#endif
+        #endif
 
         case MP_BC_STORE_COMP:
             DECODE_UINT;
@@ -446,25 +446,25 @@
 
         case MP_BC_MAKE_FUNCTION:
             DECODE_PTR;
-            printf("MAKE_FUNCTION %p", (void*)(uintptr_t)unum);
+            printf("MAKE_FUNCTION %p", (void *)(uintptr_t)unum);
             break;
 
         case MP_BC_MAKE_FUNCTION_DEFARGS:
             DECODE_PTR;
-            printf("MAKE_FUNCTION_DEFARGS %p", (void*)(uintptr_t)unum);
+            printf("MAKE_FUNCTION_DEFARGS %p", (void *)(uintptr_t)unum);
             break;
 
         case MP_BC_MAKE_CLOSURE: {
             DECODE_PTR;
             mp_uint_t n_closed_over = *ip++;
-            printf("MAKE_CLOSURE %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over);
+            printf("MAKE_CLOSURE %p " UINT_FMT, (void *)(uintptr_t)unum, n_closed_over);
             break;
         }
 
         case MP_BC_MAKE_CLOSURE_DEFARGS: {
             DECODE_PTR;
             mp_uint_t n_closed_over = *ip++;
-            printf("MAKE_CLOSURE_DEFARGS %p " UINT_FMT, (void*)(uintptr_t)unum, n_closed_over);
+            printf("MAKE_CLOSURE_DEFARGS %p " UINT_FMT, (void *)(uintptr_t)unum, n_closed_over);
             break;
         }
 
diff --git a/py/stackctrl.c b/py/stackctrl.c
index 5c07796..c2f3adb 100644
--- a/py/stackctrl.c
+++ b/py/stackctrl.c
@@ -29,7 +29,7 @@
 
 void mp_stack_ctrl_init(void) {
     volatile int stack_dummy;
-    MP_STATE_THREAD(stack_top) = (char*)&stack_dummy;
+    MP_STATE_THREAD(stack_top) = (char *)&stack_dummy;
 }
 
 void mp_stack_set_top(void *top) {
@@ -39,7 +39,7 @@
 mp_uint_t mp_stack_usage(void) {
     // Assumes descending stack
     volatile int stack_dummy;
-    return MP_STATE_THREAD(stack_top) - (char*)&stack_dummy;
+    return MP_STATE_THREAD(stack_top) - (char *)&stack_dummy;
 }
 
 #if MICROPY_STACK_CHECK
diff --git a/py/stream.c b/py/stream.c
index d795681..9d87eb1 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -227,7 +227,7 @@
 
 mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, size_t len, byte flags) {
     int error;
-    mp_uint_t out_sz = mp_stream_rw(self_in, (void*)buf, len, &error, flags);
+    mp_uint_t out_sz = mp_stream_rw(self_in, (void *)buf, len, &error, flags);
     if (error != 0) {
         if (mp_is_nonblocking_error(error)) {
             // http://docs.python.org/3/library/io.html#io.RawIOBase.write
@@ -261,7 +261,7 @@
         }
     }
     bufinfo.len -= off;
-    return mp_stream_write(args[0], (byte*)bufinfo.buf + off, MIN(bufinfo.len, max_len), MP_STREAM_RW_WRITE);
+    return mp_stream_write(args[0], (byte *)bufinfo.buf + off, MIN(bufinfo.len, max_len), MP_STREAM_RW_WRITE);
 }
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_stream_write_obj, 2, 4, stream_write_method);
 
@@ -378,7 +378,7 @@
             mp_raise_OSError(error);
         }
         if (out_sz == 0) {
-done:
+        done:
             // Back out previously added byte
             // Consider, what's better - read a char and get OutOfMemory (so read
             // char is lost), or allocate first as we do.
@@ -508,7 +508,7 @@
 int mp_stream_errno;
 
 ssize_t mp_stream_posix_write(void *stream, const void *buf, size_t len) {
-    mp_obj_base_t* o = stream;
+    mp_obj_base_t *o = stream;
     const mp_stream_p_t *stream_p = o->type->protocol;
     mp_uint_t out_sz = stream_p->write(MP_OBJ_FROM_PTR(stream), buf, len, &mp_stream_errno);
     if (out_sz == MP_STREAM_ERROR) {
@@ -519,7 +519,7 @@
 }
 
 ssize_t mp_stream_posix_read(void *stream, void *buf, size_t len) {
-    mp_obj_base_t* o = stream;
+    mp_obj_base_t *o = stream;
     const mp_stream_p_t *stream_p = o->type->protocol;
     mp_uint_t out_sz = stream_p->read(MP_OBJ_FROM_PTR(stream), buf, len, &mp_stream_errno);
     if (out_sz == MP_STREAM_ERROR) {
@@ -530,7 +530,7 @@
 }
 
 off_t mp_stream_posix_lseek(void *stream, off_t offset, int whence) {
-    const mp_obj_base_t* o = stream;
+    const mp_obj_base_t *o = stream;
     const mp_stream_p_t *stream_p = o->type->protocol;
     struct mp_stream_seek_t seek_s;
     seek_s.offset = offset;
@@ -543,7 +543,7 @@
 }
 
 int mp_stream_posix_fsync(void *stream) {
-    mp_obj_base_t* o = stream;
+    mp_obj_base_t *o = stream;
     const mp_stream_p_t *stream_p = o->type->protocol;
     mp_uint_t res = stream_p->ioctl(MP_OBJ_FROM_PTR(stream), MP_STREAM_FLUSH, 0, &mp_stream_errno);
     if (res == MP_STREAM_ERROR) {
diff --git a/py/stream.h b/py/stream.h
index 3ebd4e0..96f439c 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -95,7 +95,7 @@
 
 // Object is assumed to have a non-NULL stream protocol with valid r/w/ioctl methods
 static inline const mp_stream_p_t *mp_get_stream(mp_const_obj_t self) {
-    return (const mp_stream_p_t*)((const mp_obj_base_t*)MP_OBJ_TO_PTR(self))->type->protocol;
+    return (const mp_stream_p_t *)((const mp_obj_base_t *)MP_OBJ_TO_PTR(self))->type->protocol;
 }
 
 const mp_stream_p_t *mp_get_stream_raise(mp_obj_t self_in, int flags);
@@ -111,7 +111,7 @@
 #define MP_STREAM_RW_WRITE 2
 #define MP_STREAM_RW_ONCE  1
 mp_uint_t mp_stream_rw(mp_obj_t stream, void *buf, mp_uint_t size, int *errcode, byte flags);
-#define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte*)buf, size, err, MP_STREAM_RW_WRITE)
+#define mp_stream_write_exactly(stream, buf, size, err) mp_stream_rw(stream, (byte *)buf, size, err, MP_STREAM_RW_WRITE)
 #define mp_stream_read_exactly(stream, buf, size, err) mp_stream_rw(stream, buf, size, err, MP_STREAM_RW_READ)
 
 void mp_stream_write_adaptor(void *self, const char *buf, size_t len);
diff --git a/py/unicode.c b/py/unicode.c
index 369240e..5acaad3 100644
--- a/py/unicode.c
+++ b/py/unicode.c
@@ -71,7 +71,9 @@
 
 unichar utf8_get_char(const byte *s) {
     unichar ord = *s++;
-    if (!UTF8_IS_NONASCII(ord)) return ord;
+    if (!UTF8_IS_NONASCII(ord)) {
+        return ord;
+    }
     ord &= 0x7F;
     for (unichar mask = 0x40; ord & mask; mask >>= 1) {
         ord &= ~mask;
diff --git a/py/vstr.c b/py/vstr.c
index 6f48018..56327b5 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -140,37 +140,37 @@
 }
 
 void vstr_add_byte(vstr_t *vstr, byte b) {
-    byte *buf = (byte*)vstr_add_len(vstr, 1);
+    byte *buf = (byte *)vstr_add_len(vstr, 1);
     buf[0] = b;
 }
 
 void vstr_add_char(vstr_t *vstr, unichar c) {
-#if MICROPY_PY_BUILTINS_STR_UNICODE
+    #if MICROPY_PY_BUILTINS_STR_UNICODE
     // TODO: Can this be simplified and deduplicated?
     // Is it worth just calling vstr_add_len(vstr, 4)?
     if (c < 0x80) {
-        byte *buf = (byte*)vstr_add_len(vstr, 1);
+        byte *buf = (byte *)vstr_add_len(vstr, 1);
         *buf = (byte)c;
     } else if (c < 0x800) {
-        byte *buf = (byte*)vstr_add_len(vstr, 2);
+        byte *buf = (byte *)vstr_add_len(vstr, 2);
         buf[0] = (c >> 6) | 0xC0;
         buf[1] = (c & 0x3F) | 0x80;
     } else if (c < 0x10000) {
-        byte *buf = (byte*)vstr_add_len(vstr, 3);
+        byte *buf = (byte *)vstr_add_len(vstr, 3);
         buf[0] = (c >> 12) | 0xE0;
         buf[1] = ((c >> 6) & 0x3F) | 0x80;
         buf[2] = (c & 0x3F) | 0x80;
     } else {
         assert(c < 0x110000);
-        byte *buf = (byte*)vstr_add_len(vstr, 4);
+        byte *buf = (byte *)vstr_add_len(vstr, 4);
         buf[0] = (c >> 18) | 0xF0;
         buf[1] = ((c >> 12) & 0x3F) | 0x80;
         buf[2] = ((c >> 6) & 0x3F) | 0x80;
         buf[3] = (c & 0x3F) | 0x80;
     }
-#else
+    #else
     vstr_add_byte(vstr, c);
-#endif
+    #endif
 }
 
 void vstr_add_str(vstr_t *vstr, const char *str) {