diff --git a/py/argcheck.c b/py/argcheck.c
index 4bc0629b12a7844cb3814894b73d4829f11befba..f9a4eb7f468821581d14e7415b1662cfade039d8 100644
--- a/py/argcheck.c
+++ b/py/argcheck.c
@@ -27,12 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 void mp_arg_check_num(mp_uint_t n_args, mp_uint_t n_kw, mp_uint_t n_args_min, mp_uint_t n_args_max, bool takes_kw) {
     // TODO maybe take the function name as an argument so we can print nicer error messages
diff --git a/py/asmarm.c b/py/asmarm.c
index 51852df5f49d058458cfdaeed3830d0c97072395..0ca88fd97c65ed38084afddb89a489af9b07ec91 100644
--- a/py/asmarm.c
+++ b/py/asmarm.c
@@ -29,13 +29,13 @@
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "asmarm.h"
+#include "py/mpconfig.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_ARM
 
+#include "py/asmarm.h"
+
 #define SIGNED_FIT24(x) (((x) & 0xff800000) == 0) || (((x) & 0xff000000) == 0xff000000)
 
 struct _asm_arm_t {
diff --git a/py/asmthumb.c b/py/asmthumb.c
index 7ae6862b51b367583ee8458cb3f9e8508602bd03..14ba5a6fcd3822c3c83a015b1da8fdd36de9a96b 100644
--- a/py/asmthumb.c
+++ b/py/asmthumb.c
@@ -28,13 +28,13 @@
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "asmthumb.h"
+#include "py/mpconfig.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_THUMB || MICROPY_EMIT_INLINE_THUMB
 
+#include "py/asmthumb.h"
+
 #define UNSIGNED_FIT8(x) (((x) & 0xffffff00) == 0)
 #define UNSIGNED_FIT16(x) (((x) & 0xffff0000) == 0)
 #define SIGNED_FIT8(x) (((x) & 0xffffff80) == 0) || (((x) & 0xffffff80) == 0xffffff80)
diff --git a/py/asmx64.c b/py/asmx64.c
index 54f541ffb94f62758e92a842cd8247256d5b59e0..ded778fe09524caef74d41c7125c7cfc679207f5 100644
--- a/py/asmx64.c
+++ b/py/asmx64.c
@@ -29,13 +29,12 @@
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
+#include "py/mpconfig.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_X64
 
-#include "asmx64.h"
+#include "py/asmx64.h"
 
 /* all offsets are measured in multiples of 8 bytes */
 #define WORD_SIZE                (8)
diff --git a/py/asmx86.c b/py/asmx86.c
index f0dc1e60f5d53193138dd0781b8d0b1b0fb2e7f5..29ceaf8f87870b70cb05cf5a05b03a639f4bcc28 100644
--- a/py/asmx86.c
+++ b/py/asmx86.c
@@ -29,13 +29,12 @@
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
+#include "py/mpconfig.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_X86
 
-#include "asmx86.h"
+#include "py/asmx86.h"
 
 /* all offsets are measured in multiples of 4 bytes */
 #define WORD_SIZE                (4)
diff --git a/py/bc.c b/py/bc.c
index bbc9a207d3e6a2acaca2294f0aa4ab20512b6585..6aa20172ff9fe0b47269aea095aea50b353830f7 100644
--- a/py/bc.c
+++ b/py/bc.c
@@ -29,17 +29,9 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "objfun.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "bc.h"
-#include "stackctrl.h"
+#include "py/nlr.h"
+#include "py/objfun.h"
+#include "py/bc.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/bc.h b/py/bc.h
index ad16f9c9dfeaa05f292d90090f2ad4e0e2a360f0..45c63f356bccd1a5fc6260b0229285f45cc84699 100644
--- a/py/bc.h
+++ b/py/bc.h
@@ -23,6 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_BC_H__
+#define __MICROPY_INCLUDED_PY_BC_H__
+
+#include "py/runtime.h"
+#include "py/obj.h"
 
 // Exception stack entry
 typedef struct _mp_exc_stack {
@@ -61,3 +66,5 @@ const byte *mp_bytecode_print_str(const byte *ip);
 #define MP_TAGPTR_TAG0(x) ((mp_uint_t)(x) & 1)
 #define MP_TAGPTR_TAG1(x) ((mp_uint_t)(x) & 2)
 #define MP_TAGPTR_MAKE(ptr, tag) ((void*)((mp_uint_t)(ptr) | (tag)))
+
+#endif // __MICROPY_INCLUDED_PY_BC_H__
diff --git a/py/bc0.h b/py/bc0.h
index 0b10917595ae6efa5333fd8933d0356fc32e401e..42b8b62800f133f3f13ef333a9278f409eeabee7 100644
--- a/py/bc0.h
+++ b/py/bc0.h
@@ -23,6 +23,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_BC0_H__
+#define __MICROPY_INCLUDED_PY_BC0_H__
 
 // Micro Python byte-codes.
 // The comment at the end of the line (if it exists) tells the arguments to the byte-code.
@@ -118,3 +120,5 @@
 #define MP_BC_STORE_FAST_MULTI           (0xc0) // + N(16)
 #define MP_BC_UNARY_OP_MULTI             (0xd0) // + op(5)
 #define MP_BC_BINARY_OP_MULTI            (0xd5) // + op(35)
+
+#endif // __MICROPY_INCLUDED_PY_BC0_H__
diff --git a/py/binary.c b/py/binary.c
index e4dac31e96f5e5a9cceafb520c2939a5009e5602..69818e53614b91ed3faf72783d98c0c653b7ed07 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -30,12 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "smallint.h"
-#include "binary.h"
+#include "py/binary.h"
+#include "py/smallint.h"
 
 // Helpers to work with binary-encoded data
 
diff --git a/py/binary.h b/py/binary.h
index dc9d3f68081b40138ca2915a86897b086f155700..a0ccbd5f43e0e21708f15425b628a34abea833f6 100644
--- a/py/binary.h
+++ b/py/binary.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_BINARY_H__
+#define __MICROPY_INCLUDED_PY_BINARY_H__
+
+#include "py/obj.h"
 
 // Use special typecode to differentiate repr() of bytearray vs array.array('B')
 // (underlyingly they're same).
@@ -36,3 +40,5 @@ mp_obj_t mp_binary_get_val(char struct_type, char val_type, byte **ptr);
 void mp_binary_set_val(char struct_type, char val_type, mp_obj_t val_in, byte **ptr);
 long long mp_binary_get_int(mp_uint_t size, bool is_signed, bool big_endian, const byte *src);
 void mp_binary_set_int(mp_uint_t val_sz, bool big_endian, byte *dest, mp_uint_t val);
+
+#endif // __MICROPY_INCLUDED_PY_BINARY_H__
diff --git a/py/builtin.h b/py/builtin.h
index 70f1633791db25ef4122295d8be256664f0f04f0..14dc273246e206160adaaaf13178a06b2d678de5 100644
--- a/py/builtin.h
+++ b/py/builtin.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_BUILTIN_H__
+#define __MICROPY_INCLUDED_PY_BUILTIN_H__
+
+#include "py/obj.h"
 
 mp_obj_t mp_builtin___import__(mp_uint_t n_args, const mp_obj_t *args);
 mp_obj_t mp_builtin_open(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
@@ -101,3 +105,5 @@ extern const mp_obj_module_t mp_module_ure;
 extern const mp_obj_module_t mp_module_uheapq;
 extern const mp_obj_module_t mp_module_uhashlib;
 extern const mp_obj_module_t mp_module_ubinascii;
+
+#endif // __MICROPY_INCLUDED_PY_BUILTIN_H__
diff --git a/py/builtinevex.c b/py/builtinevex.c
index bb15fd4d0f33967054ebea9f205df50433b35a81..9bca4a0f53dfd87e678b5ba82352898047b115c1 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -26,20 +26,11 @@
 
 #include <stdint.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "lexerunix.h"
-#include "parse.h"
-#include "obj.h"
-#include "objfun.h"
-#include "parsehelper.h"
-#include "compile.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "builtin.h"
+#include "py/nlr.h"
+#include "py/objfun.h"
+#include "py/compile.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_BUILTINS_COMPILE
 
diff --git a/py/builtinimport.c b/py/builtinimport.c
index fd804ee3563105a981d3ab1b0cfab1ede4016818..4dc02bdc22c8f002128e04242dcc864c238cf162 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -25,25 +25,15 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "lexerunix.h"
-#include "parse.h"
-#include "obj.h"
-#include "objmodule.h"
-#include "parsehelper.h"
-#include "compile.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "builtin.h"
+#include "py/nlr.h"
+#include "py/compile.h"
+#include "py/objmodule.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/compile.c b/py/compile.c
index 66e2996c445f8e58bfeaa428e33f9071bc9793df..b2ba01cc9d9352c99a59b8a6775791ed1c8598ba 100644
--- a/py/compile.c
+++ b/py/compile.c
@@ -31,26 +31,18 @@
 #include <assert.h>
 #include <math.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "runtime0.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "emit.h"
-#include "compile.h"
-#include "runtime.h"
-#include "builtin.h"
-#include "smallint.h"
+#include "py/scope.h"
+#include "py/emit.h"
+#include "py/compile.h"
+#include "py/smallint.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
 
 // TODO need to mangle __attr names
 
 typedef enum {
 #define DEF_RULE(rule, comp, kind, ...) PN_##rule,
-#include "grammar.h"
+#include "py/grammar.h"
 #undef DEF_RULE
     PN_maximum_number_of,
     PN_string, // special node for non-interned string
@@ -2937,7 +2929,7 @@ STATIC compile_function_t compile_function[] = {
 #define nc NULL
 #define c(f) compile_##f
 #define DEF_RULE(rule, comp, kind, ...) comp,
-#include "grammar.h"
+#include "py/grammar.h"
 #undef nc
 #undef c
 #undef DEF_RULE
diff --git a/py/emit.h b/py/emit.h
index f039770a5c68b5795da4ae08e062209170b28c78..49bb76eadb1b48655733e463e81439406f23a936 100644
--- a/py/emit.h
+++ b/py/emit.h
@@ -24,6 +24,13 @@
  * THE SOFTWARE.
  */
 
+#ifndef __MICROPY_INCLUDED_PY_EMIT_H__
+#define __MICROPY_INCLUDED_PY_EMIT_H__
+
+#include "py/lexer.h"
+#include "py/scope.h"
+#include "py/runtime0.h"
+
 /* Notes on passes:
  * We don't know exactly the opcodes in pass 1 because they depend on the
  * closing over of variables (LOAD_CLOSURE, BUILD_TUPLE, MAKE_CLOSURE), which
@@ -33,10 +40,6 @@
  * This is problematic for some emitters (x64) since they need to know the maximum
  * stack size to compile the entry to the function, and this affects code size.
  */
-#ifndef __MICROPY_INCLUDED_PY_EMIT_H__
-#define __MICROPY_INCLUDED_PY_EMIT_H__
-
-#include "py/runtime0.h"
 
 typedef enum {
     MP_PASS_SCOPE = 1,      // work out id's and their kind, and number of labels
diff --git a/py/emitbc.c b/py/emitbc.c
index f55a16634a326ead18ae5689020a6e549f794a45..3914a9dcbfcd969ca6af8d7b501dcccf591f2864 100644
--- a/py/emitbc.c
+++ b/py/emitbc.c
@@ -30,17 +30,8 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "runtime0.h"
-#include "emit.h"
-#include "bc0.h"
+#include "py/emit.h"
+#include "py/bc0.h"
 
 #if !MICROPY_EMIT_CPYTHON
 
diff --git a/py/emitcommon.c b/py/emitcommon.c
index e199bc6e9c099cccdaa35b88d3a5af139bf1358d..4d909839ad6dbd2305326b5e27faa6f892e7edcf 100644
--- a/py/emitcommon.c
+++ b/py/emitcommon.c
@@ -28,16 +28,7 @@
 #include <stdint.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "runtime0.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "emit.h"
+#include "py/emit.h"
 
 #define EMIT(fun, ...) (emit_method_table->fun(emit, __VA_ARGS__))
 
diff --git a/py/emitcpy.c b/py/emitcpy.c
index bcf8a22c3ab4a8f86c97dcd2cdf8359f3cfcb06c..a1e8e95c8ccfbd7478c91e4c1922b4db203e4898 100644
--- a/py/emitcpy.c
+++ b/py/emitcpy.c
@@ -30,16 +30,7 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "runtime0.h"
-#include "emit.h"
+#include "py/emit.h"
 
 // wrapper around everything in this file
 #if MICROPY_EMIT_CPYTHON
diff --git a/py/emitglue.c b/py/emitglue.c
index 5d51ba2a68f8e7a2efc294fea120b9efbabdaa0a..65d131125fe97f3d8b5b75bd9adf0993af4f9c07 100644
--- a/py/emitglue.c
+++ b/py/emitglue.c
@@ -30,14 +30,9 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "emitglue.h"
-#include "bc.h"
+#include "py/emitglue.h"
+#include "py/runtime0.h"
+#include "py/bc.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/emitglue.h b/py/emitglue.h
index 60ccd674060fe50a1ca76e2cf95cef06d3b5f097..6e7e72ef5ae3380f998f6a8dab1c019b6c320aa9 100644
--- a/py/emitglue.h
+++ b/py/emitglue.h
@@ -26,6 +26,8 @@
 #ifndef __MICROPY_INCLUDED_PY_EMITGLUE_H__
 #define __MICROPY_INCLUDED_PY_EMITGLUE_H__
 
+#include "py/obj.h"
+
 // These variables and functions glue the code emitters to the runtime.
 
 typedef enum {
diff --git a/py/emitinlinethumb.c b/py/emitinlinethumb.c
index 4cf880fab77b5407ae6ebe7a499599540130afda..669929b0d1b938e8d86d538c1d9c235a5c6b7132 100644
--- a/py/emitinlinethumb.c
+++ b/py/emitinlinethumb.c
@@ -30,23 +30,14 @@
 #include <stdarg.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "runtime0.h"
-#include "emit.h"
-#include "asmthumb.h"
+#include "py/emit.h"
+#include "py/asmthumb.h"
 
 #if MICROPY_EMIT_INLINE_THUMB
 
 typedef enum {
 #define DEF_RULE(rule, comp, kind, ...) PN_##rule,
-#include "grammar.h"
+#include "py/grammar.h"
 #undef DEF_RULE
     PN_maximum_number_of,
 } pn_kind_t;
diff --git a/py/emitnative.c b/py/emitnative.c
index c8f8cd8f241438052307cb2cfa31a11bcb2f1db6..494f89093d6fd12e49916b7a6a86ca6e4d9b553a 100644
--- a/py/emitnative.c
+++ b/py/emitnative.c
@@ -42,24 +42,12 @@
 
 // for x in l[0:8]: can be compiled into a native loop if l has pointer type
 
-#include <stdbool.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "runtime0.h"
-#include "emit.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/emit.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
@@ -78,7 +66,7 @@
 
 // x64 specific stuff
 
-#include "asmx64.h"
+#include "py/asmx64.h"
 
 #define EXPORT_FUN(name) emit_native_x64_##name
 
@@ -163,7 +151,7 @@
 
 // x86 specific stuff
 
-#include "asmx86.h"
+#include "py/asmx86.h"
 
 STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
     [MP_F_CONVERT_OBJ_TO_NATIVE] = 2,
@@ -295,7 +283,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
 
 // thumb specific stuff
 
-#include "asmthumb.h"
+#include "py/asmthumb.h"
 
 #define EXPORT_FUN(name) emit_native_thumb_##name
 
@@ -378,7 +366,7 @@ STATIC byte mp_f_n_args[MP_F_NUMBER_OF] = {
 
 // ARM specific stuff
 
-#include "asmarm.h"
+#include "py/asmarm.h"
 
 #define EXPORT_FUN(name) emit_native_arm_##name
 
diff --git a/py/emitpass1.c b/py/emitpass1.c
index 9e471ef59f373770371fc3f9b581ae3901dc1a0e..8878b562e37ebe47784daed7c36dd78813793d03 100644
--- a/py/emitpass1.c
+++ b/py/emitpass1.c
@@ -24,20 +24,9 @@
  * THE SOFTWARE.
  */
 
-#include <stdlib.h>
-#include <stdint.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "scope.h"
-#include "runtime0.h"
-#include "emit.h"
+#include "py/emit.h"
 
 struct _emit_t {
     scope_t *scope;
diff --git a/py/formatfloat.c b/py/formatfloat.c
index d1b12cdd5bcf65185e843e015267a49956314a2e..e73215a7a83d6016824e77d8bbf8668f0c74beb6 100644
--- a/py/formatfloat.c
+++ b/py/formatfloat.c
@@ -42,10 +42,11 @@
 #include <stdlib.h>
 #include <stdint.h>
 
-#include "mpconfig.h"
+#include "py/mpconfig.h"
 
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
-#include "formatfloat.h"
+
+#include "py/formatfloat.h"
 
 // 1 sign bit, 8 exponent bits, and 23 mantissa bits.
 // exponent values 0 and 255 are reserved, exponent can be 1 to 254.
@@ -63,7 +64,7 @@ static const float g_neg_pow[] = {
     1e-32, 1e-16, 1e-8, 1e-4, 1e-2, 1e-1
 };
 
-int format_float(float f, char *buf, size_t buf_size, char fmt, int prec, char sign) {
+int mp_format_float(float f, char *buf, size_t buf_size, char fmt, int prec, char sign) {
 
     char *s = buf;
     int buf_remaining = buf_size - 1;
diff --git a/py/formatfloat.h b/py/formatfloat.h
index 3b963df414ef00978c7a987d9f99f21700a57faf..1eb2c1e46f2751af08b401bf1f41ffb24520533e 100644
--- a/py/formatfloat.h
+++ b/py/formatfloat.h
@@ -23,5 +23,9 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_FORMATFLOAT_H__
+#define __MICROPY_INCLUDED_PY_FORMATFLOAT_H__
 
-int format_float(float f, char *buf, size_t bufSize, char fmt, int prec, char sign);
+int mp_format_float(float f, char *buf, size_t bufSize, char fmt, int prec, char sign);
+
+#endif // __MICROPY_INCLUDED_PY_FORMATFLOAT_H__
diff --git a/py/gc.c b/py/gc.c
index 4d9334056503b9a52fc9d16e7dd80818f5bc7760..8404281e46bce01b09f1c96e1d48ae4ee5edb053 100644
--- a/py/gc.c
+++ b/py/gc.c
@@ -27,16 +27,10 @@
 #include <assert.h>
 #include <stdio.h>
 #include <string.h>
-#include <stdbool.h>
-#include <stdint.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "gc.h"
-
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/gc.h"
+#include "py/obj.h"
+#include "py/runtime.h"
 
 #if MICROPY_ENABLE_GC
 
diff --git a/py/gc.h b/py/gc.h
index 69fe83752b722feb6591bdc6c216d77943c7555c..c698c7d21d2099c22448b17b851d0998271735bc 100644
--- a/py/gc.h
+++ b/py/gc.h
@@ -23,6 +23,13 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_GC_H__
+#define __MICROPY_INCLUDED_PY_GC_H__
+
+#include <stdint.h>
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 void gc_init(void *start, void *end);
 
@@ -60,3 +67,5 @@ typedef struct _gc_info_t {
 void gc_info(gc_info_t *info);
 void gc_dump_info(void);
 void gc_dump_alloc_table(void);
+
+#endif // __MICROPY_INCLUDED_PY_GC_H__
diff --git a/py/lexer.c b/py/lexer.c
index bc1b8babf3416d22a5f455889d7999cc96606967..ce6aa783a2e9393e6447f6405228b3fd392d5369 100644
--- a/py/lexer.c
+++ b/py/lexer.c
@@ -24,18 +24,10 @@
  * THE SOFTWARE.
  */
 
-/* lexer.c -- simple tokeniser for Python implementation
- */
-
-#include <stdbool.h>
-#include <stdint.h>
 #include <stdio.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
+#include "py/lexer.h"
 
 #define TAB_SIZE (8)
 
diff --git a/py/lexer.h b/py/lexer.h
index 7f8d93b1ea73ed0948ce85403f868ee37fd96456..c2d2b678a02534f95a547e7b0871668183d96765 100644
--- a/py/lexer.h
+++ b/py/lexer.h
@@ -26,6 +26,11 @@
 #ifndef __MICROPY_INCLUDED_PY_LEXER_H__
 #define __MICROPY_INCLUDED_PY_LEXER_H__
 
+#include <stdint.h>
+
+#include "py/mpconfig.h"
+#include "py/qstr.h"
+
 /* lexer.h -- simple tokeniser for Micro Python
  *
  * Uses (byte) length instead of null termination.
diff --git a/py/lexerstr.c b/py/lexerstr.c
index c3456b9bd2d59ccedcb4873501d1e35acfa70055..cab3ed3612225adca8fbed9285ab8f448ed21183 100644
--- a/py/lexerstr.c
+++ b/py/lexerstr.c
@@ -24,12 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
+#include "py/lexer.h"
 
 typedef struct _mp_lexer_str_buf_t {
     mp_uint_t free_len;         // if > 0, src_beg will be freed when done by: m_free(src_beg, free_len)
diff --git a/py/lexerunix.c b/py/lexerunix.c
index 8e3241ad01cc7958a601f22a734762f073a6a892..b5abbc8fe5e1fe0235fa1f698254a98560f1acb8 100644
--- a/py/lexerunix.c
+++ b/py/lexerunix.c
@@ -24,8 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
+#include "py/mpconfig.h"
 
 #if MICROPY_HELPER_LEXER_UNIX
 
@@ -36,9 +35,7 @@
 #include <sys/stat.h>
 #include <sys/types.h>
 
-#include "qstr.h"
-#include "lexer.h"
-#include "lexerunix.h"
+#include "py/lexer.h"
 
 typedef struct _mp_lexer_file_buf_t {
     int fd;
diff --git a/py/lexerunix.h b/py/lexerunix.h
deleted file mode 100644
index 12c3e8712bf20f7251848f4f5ef073c8550ceb4e..0000000000000000000000000000000000000000
--- a/py/lexerunix.h
+++ /dev/null
@@ -1,29 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-mp_lexer_t *mp_lexer_new_from_file(const char *filename);
-
-void mp_import_set_directory(const char *dir);
diff --git a/py/malloc.c b/py/malloc.c
index 451e480e8e4acd0e382acf10d5a3b235c980b32d..10e3566e8e2ad2e4d418f90b153f4ddb129075f9 100644
--- a/py/malloc.c
+++ b/py/malloc.c
@@ -27,10 +27,9 @@
 #include <stdio.h>
 #include <stdlib.h>
 #include <string.h>
-#include <stdint.h>
 
-#include "mpconfig.h"
-#include "misc.h"
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 #if 0 // print debugging info
 #define DEBUG_printf DEBUG_printf
@@ -47,7 +46,7 @@ STATIC size_t peak_bytes_allocated = 0;
 #endif
 
 #if MICROPY_ENABLE_GC
-#include "gc.h"
+#include "py/gc.h"
 
 // We redirect standard alloc functions to GC heap - just for the rest of
 // this module. In the rest of micropython source, system malloc can be
diff --git a/py/map.c b/py/map.c
index 22580de821e55054f6d151c2ddc5b46f9038a672..c88e6e56e3b8f5b5d2573196167cc2d957beff5d 100644
--- a/py/map.c
+++ b/py/map.c
@@ -28,11 +28,9 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
+#include "py/mpconfig.h"
+#include "py/misc.h"
+#include "py/obj.h"
 
 // Fixed empty map. Useful when need to call kw-receiving functions
 // without any keywords from C, etc.
diff --git a/py/modarray.c b/py/modarray.c
index 360fe8a5f162f4cb6c64ab41812d3c61b6c337ff..e251b06880173a7764b8d0d05b9a376c34cc6d64 100644
--- a/py/modarray.c
+++ b/py/modarray.c
@@ -24,11 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_ARRAY
 
diff --git a/py/modbuiltins.c b/py/modbuiltins.c
index 7ac22fc49f0e091c3b0d95b3fd6a8737952c50d8..4a1446d2331a9cc8fe18253a1f0eba35a7b16cb8 100644
--- a/py/modbuiltins.c
+++ b/py/modbuiltins.c
@@ -27,18 +27,14 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objstr.h"
-#include "smallint.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "builtin.h"
-#include "stream.h"
-#include "pfenv.h"
+#include "py/nlr.h"
+#include "py/smallint.h"
+#include "py/objstr.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
+#include "py/stream.h"
+#include "py/pfenv.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 #include <math.h>
diff --git a/py/modcmath.c b/py/modcmath.c
index 7514a8c029166cc4e4ea9b5348a2987a773758af..59fa76ee68f355f3bad206ee0c03dc06a0b89681 100644
--- a/py/modcmath.c
+++ b/py/modcmath.c
@@ -24,16 +24,12 @@
  * THE SOFTWARE.
  */
 
-#include <math.h>
-
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_CMATH
 
+#include <math.h>
+
 /// \module cmath - mathematical functions for complex numbers
 ///
 /// The `cmath` module provides some basic mathematical funtions for
diff --git a/py/modcollections.c b/py/modcollections.c
index 8035b72d594030fa69ab681f52d93406ad969e97..9fcbe879f25caa1bce7c065ea5103a31bf16b186 100644
--- a/py/modcollections.c
+++ b/py/modcollections.c
@@ -24,11 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_COLLECTIONS
 
diff --git a/py/modgc.c b/py/modgc.c
index 8c9be7068875cd5e253465d5f4a7d638de7fa953..e3cbe72f9db477ee3927ff9522fb4b90cbeb9ed8 100644
--- a/py/modgc.c
+++ b/py/modgc.c
@@ -24,14 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "gc.h"
+#include "py/obj.h"
+#include "py/gc.h"
 
 #if MICROPY_PY_GC && MICROPY_ENABLE_GC
 
diff --git a/py/modio.c b/py/modio.c
index 6a273b39b7e1379309004c6dbe915900730a4a44..30f766b407ef12422b97590e325184c73fa2724b 100644
--- a/py/modio.c
+++ b/py/modio.c
@@ -24,11 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_IO
 
diff --git a/py/modmath.c b/py/modmath.c
index b922f3e4906987ca2e3db59bcfd912bf4f142a05..38ed390ddfe301e2e6c731c6f5aff946e70309ee 100644
--- a/py/modmath.c
+++ b/py/modmath.c
@@ -24,16 +24,12 @@
  * THE SOFTWARE.
  */
 
-#include <math.h>
-
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT && MICROPY_PY_MATH
 
+#include <math.h>
+
 /// \module math - mathematical functions
 ///
 /// The `math` module provides some basic mathematical funtions for
diff --git a/py/modmicropython.c b/py/modmicropython.c
index 170141757957285b213c7184795511803cce7bd0..035956ffcc74bacd6413f1c51d787f6530eb6d32 100644
--- a/py/modmicropython.c
+++ b/py/modmicropython.c
@@ -24,15 +24,11 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
 #include <stdio.h>
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
-#include "stackctrl.h"
-#include "gc.h"
+
+#include "py/builtin.h"
+#include "py/stackctrl.h"
+#include "py/gc.h"
 
 // Various builtins specific to MicroPython runtime,
 // living in micropython module
diff --git a/py/modstruct.c b/py/modstruct.c
index f29c8c1f9690d9ead53797a6f4fea1b3f8006ade..114135dfd12c57a89bf6de9223a9a60a470d2be4 100644
--- a/py/modstruct.c
+++ b/py/modstruct.c
@@ -27,15 +27,11 @@
 
 #include <assert.h>
 #include <string.h>
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
-#include "objtuple.h"
-#include "objstr.h"
-#include "binary.h"
-#include "parsenum.h"
+
+#include "py/builtin.h"
+#include "py/objtuple.h"
+#include "py/binary.h"
+#include "py/parsenum.h"
 
 #if MICROPY_PY_STRUCT
 
diff --git a/py/modsys.c b/py/modsys.c
index 06bd4c80e10f2a2c40355080e7a8bc36af5f8e83..51bd6bfbb44b18df16bcf0ba5597e679966d90d2 100644
--- a/py/modsys.c
+++ b/py/modsys.c
@@ -24,22 +24,14 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "builtin.h"
-#include "runtime.h"
-#include "objlist.h"
-#include "objtuple.h"
-#include "objstr.h"
-#include "mpz.h"
-#include "objint.h"
-#include "pfenv.h"
-#include "stream.h"
+#include "py/nlr.h"
+#include "py/builtin.h"
+#include "py/objlist.h"
+#include "py/objtuple.h"
+#include "py/objstr.h"
+#include "py/objint.h"
+#include "py/pfenv.h"
+#include "py/stream.h"
 
 #if MICROPY_PY_SYS
 
diff --git a/py/mpz.c b/py/mpz.c
index 6213b4a57d46f14af3b8cc553825094f70344d2c..a25ba9e7d208bb7c7a3964c0639193da1650d8ed 100644
--- a/py/mpz.c
+++ b/py/mpz.c
@@ -24,15 +24,10 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
-#include <stdbool.h>
-#include <stdlib.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "mpz.h"
+#include "py/mpz.h"
 
 #if MICROPY_LONGINT_IMPL == MICROPY_LONGINT_IMPL_MPZ
 
diff --git a/py/mpz.h b/py/mpz.h
index 3ae9efe4211aafbbd9bbe415fa7404b66af2fc67..e1d71bf4aef7d07b685aa7212c36eae07a7a4f55 100644
--- a/py/mpz.h
+++ b/py/mpz.h
@@ -23,6 +23,13 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_MPZ_H__
+#define __MICROPY_INCLUDED_PY_MPZ_H__
+
+#include <stdint.h>
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 // This mpz module implements arbitrary precision integers.
 //
@@ -131,3 +138,5 @@ mp_float_t mpz_as_float(const mpz_t *z);
 #endif
 mp_uint_t mpz_as_str_size(const mpz_t *i, mp_uint_t base, const char *prefix, char comma);
 mp_uint_t mpz_as_str_inpl(const mpz_t *z, mp_uint_t base, const char *prefix, char base_char, char comma, char *str);
+
+#endif // __MICROPY_INCLUDED_PY_MPZ_H__
diff --git a/py/nativeglue.c b/py/nativeglue.c
index 05fadb7b0df30009a32ab206cb5297cd63b68b1a..d52eeaeaa5f260e2a77cbc04e7956e560d088e8f 100644
--- a/py/nativeglue.c
+++ b/py/nativeglue.c
@@ -28,14 +28,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "emitglue.h"
+#include "py/nlr.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/emitglue.h"
 
 #if MICROPY_EMIT_NATIVE
 
diff --git a/py/nlr.h b/py/nlr.h
index 93eaa78b768e6241720368963f884211dee8d74b..ae9ca1a777ffbaea32e8ea9ed89a8c1143b9e9ff 100644
--- a/py/nlr.h
+++ b/py/nlr.h
@@ -23,6 +23,8 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_NLR_H__
+#define __MICROPY_INCLUDED_PY_NLR_H__
 
 // non-local return
 // exception handling, basically a stack of setjmp/longjmp buffers
@@ -31,6 +33,8 @@
 #include <setjmp.h>
 #include <assert.h>
 
+#include "py/mpconfig.h"
+
 typedef struct _nlr_buf_t nlr_buf_t;
 struct _nlr_buf_t {
     // the entries here must all be machine word size
@@ -91,3 +95,5 @@ void nlr_jump_fail(void *val);
         nlr_jump(_val); \
     } while (0)
 #endif
+
+#endif // __MICROPY_INCLUDED_PY_NLR_H__
diff --git a/py/nlrsetjmp.c b/py/nlrsetjmp.c
index cb5acb757b8ce45b61589c8bc1e081a2776b1751..176138db04b49675b3a1ab69462fc6e5088d3524 100644
--- a/py/nlrsetjmp.c
+++ b/py/nlrsetjmp.c
@@ -24,10 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include <setjmp.h>
-#include <stdio.h>
-#include "mpconfig.h"
-#include "nlr.h"
+#include "py/nlr.h"
 
 #if MICROPY_NLR_SETJMP
 
diff --git a/py/obj.c b/py/obj.c
index d2801a39687caa91971db78fcc056b9de55cfe54..0caf100745a54e09fc10cfc7540515ab1a323cb9 100644
--- a/py/obj.c
+++ b/py/obj.c
@@ -29,17 +29,13 @@
 #include <stdarg.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtype.h"
-#include "mpz.h"
-#include "objint.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "stackctrl.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/objtype.h"
+#include "py/objint.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/stackctrl.h"
 
 mp_obj_type_t *mp_obj_get_type(mp_const_obj_t o_in) {
     if (MP_OBJ_IS_SMALL_INT(o_in)) {
diff --git a/py/objarray.c b/py/objarray.c
index cb8e03e451d69eff6e5498871ba8155d41258f5c..19705afc0213edcd2f44c8a2799bdc1ba1501d7c 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -29,14 +29,10 @@
 #include <assert.h>
 #include <stdint.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "binary.h"
+#include "py/nlr.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/binary.h"
 
 #if MICROPY_PY_ARRAY || MICROPY_PY_BUILTINS_BYTEARRAY || MICROPY_PY_BUILTINS_MEMORYVIEW
 
diff --git a/py/objarray.h b/py/objarray.h
deleted file mode 100644
index 730f67641b2f6c227de4b49534a3f40f8d08dd93..0000000000000000000000000000000000000000
--- a/py/objarray.h
+++ /dev/null
@@ -1,27 +0,0 @@
-/*
- * This file is part of the Micro Python project, http://micropython.org/
- *
- * The MIT License (MIT)
- *
- * Copyright (c) 2013, 2014 Damien P. George
- *
- * Permission is hereby granted, free of charge, to any person obtaining a copy
- * of this software and associated documentation files (the "Software"), to deal
- * in the Software without restriction, including without limitation the rights
- * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
- * copies of the Software, and to permit persons to whom the Software is
- * furnished to do so, subject to the following conditions:
- *
- * The above copyright notice and this permission notice shall be included in
- * all copies or substantial portions of the Software.
- *
- * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
- * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
- * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
- * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
- * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
- * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
- * THE SOFTWARE.
- */
-
-mp_obj_t mp_obj_new_bytearray(mp_uint_t n, void *items);
diff --git a/py/objbool.c b/py/objbool.c
index 47c91357ff541535ff2dc5f2d249b5793ff7991f..6dd9e7f9f8c3cb72e8f9f4ff78aa8d1bb66517ef 100644
--- a/py/objbool.c
+++ b/py/objbool.c
@@ -26,13 +26,9 @@
 
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_bool_t {
     mp_obj_base_t base;
diff --git a/py/objboundmeth.c b/py/objboundmeth.c
index 66af5df0a947b9355a4c0684053eedf0612b2aea..e451ce4c13095185b4bdad1015007d4feadb8541 100644
--- a/py/objboundmeth.c
+++ b/py/objboundmeth.c
@@ -26,12 +26,8 @@
 
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/obj.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_bound_meth_t {
     mp_obj_base_t base;
diff --git a/py/objcell.c b/py/objcell.c
index 29280e851bdff9279f806cecbef17527f09c525c..b2d42001bc9097e0c222eb6bae1e2ea42d653a4f 100644
--- a/py/objcell.c
+++ b/py/objcell.c
@@ -24,12 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/obj.h"
 
 typedef struct _mp_obj_cell_t {
     mp_obj_base_t base;
diff --git a/py/objclosure.c b/py/objclosure.c
index d563206b629aab2f7f8a4e1704ce9de3a6e00a6d..853f0930c03ccf49df3db578bbac7ac9ac82f44c 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -26,13 +26,8 @@
 
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "runtime.h"
+#include "py/obj.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_closure_t {
     mp_obj_base_t base;
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 2768a01e65524b0ccfa8113c500d15f5280a055b..9e158fac69b7293747610ac0bd308e1de66d3705 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -28,21 +28,18 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "parsenum.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/parsenum.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_COMPLEX
 
 #include <math.h>
 
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
-#include "formatfloat.h"
+#include "py/formatfloat.h"
 #endif
 
 typedef struct _mp_obj_complex_t {
@@ -58,12 +55,12 @@ STATIC void complex_print(void (*print)(void *env, const char *fmt, ...), void *
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
     char buf[16];
     if (o->real == 0) {
-        format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0');
+        mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0');
         print(env, "%sj", buf);
     } else {
-        format_float(o->real, buf, sizeof(buf), 'g', 7, '\0');
+        mp_format_float(o->real, buf, sizeof(buf), 'g', 7, '\0');
         print(env, "(%s+", buf);
-        format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0');
+        mp_format_float(o->imag, buf, sizeof(buf), 'g', 7, '\0');
         print(env, "%sj)", buf);
     }
 #else
diff --git a/py/objdict.c b/py/objdict.c
index 2f4ae7083059e1ac99dbacd2951932df939d9ef3..63b3cfb3290804cd630a64ed453552736d57a26b 100644
--- a/py/objdict.c
+++ b/py/objdict.c
@@ -24,19 +24,14 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "builtin.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
 
 STATIC mp_obj_t dict_update(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs);
 
diff --git a/py/objenumerate.c b/py/objenumerate.c
index 0d96712df68c1db64f056ce0f46c0f2f528bef53..209af82312fad973b63d2663aac51b949971fc80 100644
--- a/py/objenumerate.c
+++ b/py/objenumerate.c
@@ -27,11 +27,7 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_enumerate_t {
     mp_obj_base_t base;
diff --git a/py/objexcept.c b/py/objexcept.c
index 4b8d6ea08b58ae9a19ba6cd283eeac036af995bd..a60cbb82ed7e2656097c43deb92e0ef43e8b86ff 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -28,20 +28,13 @@
 #include <stdarg.h>
 #include <assert.h>
 #include <stdio.h>
-#include <stdint.h>
-
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objlist.h"
-#include "objstr.h"
-#include "objtuple.h"
-#include "objtype.h"
-#include "runtime.h"
-#include "runtime0.h"
-#include "gc.h"
+
+#include "py/nlr.h"
+#include "py/objlist.h"
+#include "py/objstr.h"
+#include "py/objtuple.h"
+#include "py/objtype.h"
+#include "py/gc.h"
 
 typedef struct _mp_obj_exception_t {
     mp_obj_base_t base;
diff --git a/py/objfilter.c b/py/objfilter.c
index 38af31674004bd26be466814266f489d02ac8115..98200f2608617f1893c0a81179ef00294719ebac 100644
--- a/py/objfilter.c
+++ b/py/objfilter.c
@@ -24,15 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include <stdlib.h>
-#include <assert.h>
-
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_filter_t {
     mp_obj_base_t base;
diff --git a/py/objfloat.c b/py/objfloat.c
index b75d0e4ba9c354ab33f0761f14b369d56c0b0fab..86b672007ea384966fe4c8998e014f2bf63bb0ca 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -30,26 +30,22 @@
 #include <assert.h>
 #include <math.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "parsenum.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/parsenum.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
-#include "formatfloat.h"
+#include "py/formatfloat.h"
 #endif
 
 STATIC void float_print(void (*print)(void *env, const char *fmt, ...), void *env, mp_obj_t o_in, mp_print_kind_t kind) {
     mp_obj_float_t *o = o_in;
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
     char buf[16];
-    format_float(o->value, buf, sizeof(buf), 'g', 7, '\0');
+    mp_format_float(o->value, buf, sizeof(buf), 'g', 7, '\0');
     print(env, "%s", buf);
     if (strchr(buf, '.') == NULL && strchr(buf, 'e') == NULL) {
         // Python floats always have decimal point
diff --git a/py/objfun.c b/py/objfun.c
index 5f95a015bc7578b76e1c3e9c00582f4b9a6cb2f9..b86d6f8dc6390b14a44b0e8060252fa7956c3c56 100644
--- a/py/objfun.c
+++ b/py/objfun.c
@@ -25,21 +25,16 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "objfun.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "bc.h"
-#include "stackctrl.h"
+#include "py/nlr.h"
+#include "py/objtuple.h"
+#include "py/objfun.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/bc.h"
+#include "py/stackctrl.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/objfun.h b/py/objfun.h
index e23fe8d529db3af58c13af77fa719ce4c1cf84f3..a5b9f2b5fd4a721cc5961e76ac9c6987858d22c3 100644
--- a/py/objfun.h
+++ b/py/objfun.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJFUN_H__
+#define __MICROPY_INCLUDED_PY_OBJFUN_H__
+
+#include "py/obj.h"
 
 typedef struct _mp_obj_fun_bc_t {
     mp_obj_base_t base;
@@ -41,3 +45,5 @@ typedef struct _mp_obj_fun_bc_t {
     //  - a single slot for kw args dict (if it takes them)
     mp_obj_t extra_args[];
 } mp_obj_fun_bc_t;
+
+#endif // __MICROPY_INCLUDED_PY_OBJFUN_H__
diff --git a/py/objgenerator.c b/py/objgenerator.c
index 646ae4fdd4c55b3641a6d5654aa5a3b234fe36f1..1b06975c96e8b0cd6bac85ea4a8ec9dffaacdd50 100644
--- a/py/objgenerator.c
+++ b/py/objgenerator.c
@@ -28,15 +28,12 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "bc.h"
-#include "objgenerator.h"
-#include "objfun.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime.h"
+#include "py/bc.h"
+#include "py/objgenerator.h"
+#include "py/objfun.h"
 
 /******************************************************************************/
 /* generator wrapper                                                          */
diff --git a/py/objgenerator.h b/py/objgenerator.h
index d0066de4e1afe483a3dfbe814cf32a959c79cf74..d1b9be478087e9d8198bcd4cfc24f9bfe70732e7 100644
--- a/py/objgenerator.h
+++ b/py/objgenerator.h
@@ -23,5 +23,12 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJGENERATOR_H__
+#define __MICROPY_INCLUDED_PY_OBJGENERATOR_H__
+
+#include "py/obj.h"
+#include "py/runtime.h"
 
 mp_vm_return_kind_t mp_obj_gen_resume(mp_obj_t self_in, mp_obj_t send_val, mp_obj_t throw_val, mp_obj_t *ret_val);
+
+#endif // __MICROPY_INCLUDED_PY_OBJGENERATOR_H__
diff --git a/py/objgetitemiter.c b/py/objgetitemiter.c
index 75b9d1c568e8d65851b1b7b9b66865b849cf26bd..2b0f7bb052fa3c446b62310d2e6a58188b16a52b 100644
--- a/py/objgetitemiter.c
+++ b/py/objgetitemiter.c
@@ -26,12 +26,8 @@
 
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 // this is a wrapper object that is turns something that has a __getitem__ method into an iterator
 
diff --git a/py/objint.c b/py/objint.c
index 0aa281edd1aadc574714cc2a2b0d7db9583e2de5..c272fd4a741851d12866ce6a39706303f2120497 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -25,22 +25,16 @@
  */
 
 #include <stdlib.h>
-#include <stdint.h>
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "parsenum.h"
-#include "smallint.h"
-#include "mpz.h"
-#include "objint.h"
-#include "objstr.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/parsenum.h"
+#include "py/smallint.h"
+#include "py/objint.h"
+#include "py/objstr.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 #include <math.h>
diff --git a/py/objint.h b/py/objint.h
index 70d182ba7d171b7d4240abd66f3c263ec96b406f..fff325df844ddc605ffaa45619a5cf3b93dd4c07 100644
--- a/py/objint.h
+++ b/py/objint.h
@@ -23,6 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJINT_H__
+#define __MICROPY_INCLUDED_PY_OBJINT_H__
+
+#include "py/mpz.h"
+#include "py/obj.h"
 
 typedef struct _mp_obj_int_t {
     mp_obj_base_t base;
@@ -45,3 +50,5 @@ bool mp_obj_int_is_positive(mp_obj_t self_in);
 mp_obj_t mp_obj_int_unary_op(mp_uint_t op, mp_obj_t o_in);
 mp_obj_t mp_obj_int_binary_op(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
 mp_obj_t mp_obj_int_binary_op_extra_cases(mp_uint_t op, mp_obj_t lhs_in, mp_obj_t rhs_in);
+
+#endif // __MICROPY_INCLUDED_PY_OBJINT_H__
diff --git a/py/objint_longlong.c b/py/objint_longlong.c
index 5f48b71340cf2b726724d6d1b316abd7fffc61d5..394ae111adaa226e1b5f25a891680a8fa3f2c0a0 100644
--- a/py/objint_longlong.c
+++ b/py/objint_longlong.c
@@ -26,19 +26,13 @@
  */
 
 #include <stdlib.h>
-#include <stdint.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "smallint.h"
-#include "mpz.h"
-#include "objint.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/smallint.h"
+#include "py/objint.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 #include <math.h>
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 1dc1def33dd0e2e7f67b452b94317eadf30e3dac..554ec965798046f4d89317419ef547b2d9522f2b 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -24,22 +24,16 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
 #include <string.h>
 #include <stdio.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "parsenumbase.h"
-#include "obj.h"
-#include "smallint.h"
-#include "mpz.h"
-#include "objint.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/parsenumbase.h"
+#include "py/smallint.h"
+#include "py/objint.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 #include <math.h>
diff --git a/py/objlist.c b/py/objlist.c
index 3e5355719e954f486776224171294f5b6218b4ff..911ddb98ab752c07990c46238bbc43cb53df4c60 100644
--- a/py/objlist.c
+++ b/py/objlist.c
@@ -27,14 +27,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "objlist.h"
+#include "py/nlr.h"
+#include "py/objlist.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 STATIC mp_obj_t mp_obj_new_list_iterator(mp_obj_list_t *list, mp_uint_t cur);
 STATIC mp_obj_list_t *list_new(mp_uint_t n);
diff --git a/py/objlist.h b/py/objlist.h
index 05a4c8d3ab2f87ee59b13397dd0303561a64561a..443ede5743b08e45e1848e24f1210680a405c88a 100644
--- a/py/objlist.h
+++ b/py/objlist.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJLIST_H__
+#define __MICROPY_INCLUDED_PY_OBJLIST_H__
+
+#include "py/obj.h"
 
 typedef struct _mp_obj_list_t {
     mp_obj_base_t base;
@@ -30,3 +34,5 @@ typedef struct _mp_obj_list_t {
     mp_uint_t len;
     mp_obj_t *items;
 } mp_obj_list_t;
+
+#endif // __MICROPY_INCLUDED_PY_OBJLIST_H__
diff --git a/py/objmap.c b/py/objmap.c
index f7d7b01c3acb38f139514a2eee6b35d70cd6558b..ea62bb512f873852edd49e72c23732a616e1d61f 100644
--- a/py/objmap.c
+++ b/py/objmap.c
@@ -27,12 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_map_t {
     mp_obj_base_t base;
diff --git a/py/objmodule.c b/py/objmodule.c
index 5ffb368bf5c524a25433d292459f997365ad861e..2e53bf0521da7cf804f4bbe67646c9f7f3ad7b08 100644
--- a/py/objmodule.c
+++ b/py/objmodule.c
@@ -27,14 +27,10 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objmodule.h"
-#include "runtime.h"
-#include "builtin.h"
+#include "py/nlr.h"
+#include "py/objmodule.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
 
 STATIC mp_map_t mp_loaded_modules_map; // TODO: expose as sys.modules
 
diff --git a/py/objmodule.h b/py/objmodule.h
index f4ccedee570eadf97fad4a39c1307942dd0bad45..138f942c216398c025a39092bf1ec8db9fc360bc 100644
--- a/py/objmodule.h
+++ b/py/objmodule.h
@@ -23,8 +23,14 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJMODULE_H__
+#define __MICROPY_INCLUDED_PY_OBJMODULE_H__
+
+#include "py/obj.h"
 
 void mp_module_init(void);
 void mp_module_deinit(void);
 mp_obj_t mp_module_get(qstr module_name);
 void mp_module_register(qstr qstr, mp_obj_t module);
+
+#endif // __MICROPY_INCLUDED_PY_OBJMODULE_H__
diff --git a/py/objnamedtuple.c b/py/objnamedtuple.c
index c0510081c3df64123e841846e8b679740508c286..320467eed5884611e42937b84f58f7316251d563 100644
--- a/py/objnamedtuple.c
+++ b/py/objnamedtuple.c
@@ -27,13 +27,9 @@
 
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "nlr.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/objtuple.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_COLLECTIONS
 
diff --git a/py/objnone.c b/py/objnone.c
index 01536dcb34029d948627088a34e9e0403d9c6f8b..387fb58cb62b288d94f615b113c4c8d0b7f8b2c4 100644
--- a/py/objnone.c
+++ b/py/objnone.c
@@ -26,12 +26,9 @@
 
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
 
 typedef struct _mp_obj_none_t {
     mp_obj_base_t base;
diff --git a/py/objobject.c b/py/objobject.c
index 551ccf76ea37203b98a695c899fa02d7b38319a0..5bbe02b328a91a1afc3a895930468d73cb82bd7c 100644
--- a/py/objobject.c
+++ b/py/objobject.c
@@ -26,12 +26,9 @@
 
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
 
 mp_obj_t instance_make_new(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
 
diff --git a/py/objproperty.c b/py/objproperty.c
index c83ca2dbb00312fa5e66b5f73daff5213f005210..75cc1458ea191b818b7ed637f6f2ced90479f651 100644
--- a/py/objproperty.c
+++ b/py/objproperty.c
@@ -27,12 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 #if MICROPY_PY_BUILTINS_PROPERTY
 
diff --git a/py/objrange.c b/py/objrange.c
index 702413f2a953f57759450a974c31b373a02c3cfd..2a8388b172a005256d8be7e35a0eefdd305902e3 100644
--- a/py/objrange.c
+++ b/py/objrange.c
@@ -26,13 +26,9 @@
 
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 /******************************************************************************/
 /* range iterator                                                             */
diff --git a/py/objreversed.c b/py/objreversed.c
index aa73f3771065bfc08a1512ba87e82aea2889645b..b614958611b0e0f15c46afd2bd5e4398066b2143 100644
--- a/py/objreversed.c
+++ b/py/objreversed.c
@@ -27,12 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_reversed_t {
     mp_obj_base_t base;
diff --git a/py/objset.c b/py/objset.c
index 1069cd5eac61093acb313b6f972a2f60a137ad6f..54009a1f53397aea0ef80ba1d6c3f9914011fc61 100644
--- a/py/objset.c
+++ b/py/objset.c
@@ -28,14 +28,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "runtime0.h"
-#include "builtin.h"
+#include "py/nlr.h"
+#include "py/runtime.h"
+#include "py/runtime0.h"
+#include "py/builtin.h"
 
 #if MICROPY_PY_BUILTINS_SET
 
diff --git a/py/objslice.c b/py/objslice.c
index c99b9d08dbf4a2113aba3446262f8aed09f11c97..3f090dc2377bb1fb632050e40e563a62b12e3c80 100644
--- a/py/objslice.c
+++ b/py/objslice.c
@@ -27,12 +27,9 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
 
 /******************************************************************************/
 /* ellipsis object, a singleton                                               */
diff --git a/py/objstr.c b/py/objstr.c
index 3d9fd6f5e83c66a19d97648002e3a80d75a92c68..5976e36e71727e048d19f4306b2d77882a3602ca 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -25,21 +25,16 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "unicode.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "pfenv.h"
-#include "objstr.h"
-#include "objlist.h"
+#include "py/nlr.h"
+#include "py/unicode.h"
+#include "py/objstr.h"
+#include "py/objlist.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/pfenv.h"
 
 STATIC mp_obj_t str_modulo_format(mp_obj_t pattern, mp_uint_t n_args, const mp_obj_t *args, mp_obj_t dict);
 
diff --git a/py/objstr.h b/py/objstr.h
index 9bc0600852cf3d148f26d534983394e72a16fd6d..8894c267e30a792b0edb7790009b0a47211e7aa1 100644
--- a/py/objstr.h
+++ b/py/objstr.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJSTR_H__
+#define __MICROPY_INCLUDED_PY_OBJSTR_H__
+
+#include "py/obj.h"
 
 typedef struct _mp_obj_str_t {
     mp_obj_base_t base;
@@ -85,3 +89,5 @@ MP_DECLARE_CONST_FUN_OBJ(str_isalpha_obj);
 MP_DECLARE_CONST_FUN_OBJ(str_isdigit_obj);
 MP_DECLARE_CONST_FUN_OBJ(str_isupper_obj);
 MP_DECLARE_CONST_FUN_OBJ(str_islower_obj);
+
+#endif // __MICROPY_INCLUDED_PY_OBJSTR_H__
diff --git a/py/objstringio.c b/py/objstringio.c
index e5abc0526f3022231a4c8563a97173a4373ce9b0..eca8522eefca51159cc8be1b53e812a3e7224116 100644
--- a/py/objstringio.c
+++ b/py/objstringio.c
@@ -28,14 +28,10 @@
 #include <stdio.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "stream.h"
-#include "objstr.h"
+#include "py/nlr.h"
+#include "py/objstr.h"
+#include "py/runtime.h"
+#include "py/stream.h"
 
 #if MICROPY_PY_IO
 
diff --git a/py/objstrunicode.c b/py/objstrunicode.c
index 2c8d02491f6c8c4a24528a8c13f9520fca246b7d..fd3678722c8cbc4fa42e879e928b9044af79cbf9 100644
--- a/py/objstrunicode.c
+++ b/py/objstrunicode.c
@@ -25,20 +25,15 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "pfenv.h"
-#include "objstr.h"
-#include "objlist.h"
+#include "py/nlr.h"
+#include "py/objstr.h"
+#include "py/objlist.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/pfenv.h"
 
 #if MICROPY_PY_BUILTINS_STR_UNICODE
 
diff --git a/py/objtuple.c b/py/objtuple.c
index 2793e4838dd448d77ed147a7ce36984255fdcc6b..1f2eeb380dac516fa6693f3b0b7d1ecdf6561429 100644
--- a/py/objtuple.c
+++ b/py/objtuple.c
@@ -27,14 +27,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "objtuple.h"
+#include "py/nlr.h"
+#include "py/objtuple.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 STATIC mp_obj_t mp_obj_new_tuple_iterator(mp_obj_tuple_t *tuple, mp_uint_t cur);
 
diff --git a/py/objtuple.h b/py/objtuple.h
index 43b3826bf5e961867af5387f38c33b79228b5840..4cac487557a07f6ec0b71f6498c475260f55fcbd 100644
--- a/py/objtuple.h
+++ b/py/objtuple.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJTUPLE_H__
+#define __MICROPY_INCLUDED_PY_OBJTUPLE_H__
+
+#include "py/obj.h"
 
 typedef struct _mp_obj_tuple_t {
     mp_obj_base_t base;
@@ -35,3 +39,5 @@ mp_obj_t mp_obj_tuple_unary_op(mp_uint_t op, mp_obj_t self_in);
 mp_obj_t mp_obj_tuple_binary_op(mp_uint_t op, mp_obj_t lhs, mp_obj_t rhs);
 mp_obj_t mp_obj_tuple_subscr(mp_obj_t base, mp_obj_t index, mp_obj_t value);
 mp_obj_t mp_obj_tuple_getiter(mp_obj_t o_in);
+
+#endif // __MICROPY_INCLUDED_PY_OBJTUPLE_H__
diff --git a/py/objtype.c b/py/objtype.c
index 2970e92767b50f2ac4d9aa6e7de85e6e036a8d5a..b5890c472638e02cc8d34cec90064a9ac89045cb 100644
--- a/py/objtype.c
+++ b/py/objtype.c
@@ -30,14 +30,10 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "objtype.h"
+#include "py/nlr.h"
+#include "py/objtype.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/objtype.h b/py/objtype.h
index dd2e44a799cdb7714ddf43553048705b59a2edd4..8adbbc33b5b4f8e789c95f0893e44365c1563406 100644
--- a/py/objtype.h
+++ b/py/objtype.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJTYPE_H__
+#define __MICROPY_INCLUDED_PY_OBJTYPE_H__
+
+#include "py/obj.h"
 
 // instance object
 // creating an instance of a class makes one of these objects
@@ -36,3 +40,5 @@ typedef struct _mp_obj_instance_t {
 // these need to be exposed so mp_obj_is_callable can work correctly
 bool mp_obj_instance_is_callable(mp_obj_t self_in);
 mp_obj_t mp_obj_instance_call(mp_obj_t self_in, mp_uint_t n_args, mp_uint_t n_kw, const mp_obj_t *args);
+
+#endif // __MICROPY_INCLUDED_PY_OBJTYPE_H__
diff --git a/py/objzip.c b/py/objzip.c
index 738131f9203744dd5a83450e9403b0b14257952f..e1bf92737abd6467f3a27037878d0fdc7796d97c 100644
--- a/py/objzip.c
+++ b/py/objzip.c
@@ -27,12 +27,8 @@
 #include <stdlib.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "runtime.h"
+#include "py/objtuple.h"
+#include "py/runtime.h"
 
 typedef struct _mp_obj_zip_t {
     mp_obj_base_t base;
diff --git a/py/opmethods.c b/py/opmethods.c
index ea930c28a3dc48ea4c743deffa8f49bb05b4e624..80a953fb89f97fec9e50237141e5c25ecca75f4f 100644
--- a/py/opmethods.c
+++ b/py/opmethods.c
@@ -24,14 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "runtime0.h"
-#include "builtin.h"
+#include "py/runtime0.h"
+#include "py/builtin.h"
 
 STATIC mp_obj_t op_getitem(mp_obj_t self_in, mp_obj_t key_in) {
     mp_obj_type_t *type = mp_obj_get_type(self_in);
diff --git a/py/parse.c b/py/parse.c
index ae1fe65e75685437ac0479bd8e6bb64a6413853c..c7c85e035719d12084fda7390fad5cfbfef66f3e 100644
--- a/py/parse.c
+++ b/py/parse.c
@@ -30,13 +30,10 @@
 #include <assert.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parsenumbase.h"
-#include "parse.h"
-#include "smallint.h"
+#include "py/lexer.h"
+#include "py/parse.h"
+#include "py/parsenum.h"
+#include "py/smallint.h"
 
 #define RULE_ACT_ARG_MASK       (0x0f)
 #define RULE_ACT_KIND_MASK      (0x30)
@@ -69,7 +66,7 @@ typedef struct _rule_t {
 
 enum {
 #define DEF_RULE(rule, comp, kind, ...) RULE_##rule,
-#include "grammar.h"
+#include "py/grammar.h"
 #undef DEF_RULE
     RULE_maximum_number_of,
     RULE_string, // special node for non-interned string
@@ -91,7 +88,7 @@ enum {
 #else
 #define DEF_RULE(rule, comp, kind, ...) static const rule_t rule_##rule = { RULE_##rule, kind, { __VA_ARGS__ } };
 #endif
-#include "grammar.h"
+#include "py/grammar.h"
 #undef or
 #undef and
 #undef list
@@ -105,7 +102,7 @@ enum {
 
 STATIC const rule_t *rules[] = {
 #define DEF_RULE(rule, comp, kind, ...) &rule_##rule,
-#include "grammar.h"
+#include "py/grammar.h"
 #undef DEF_RULE
 };
 
diff --git a/py/parse.h b/py/parse.h
index 40062231819788442c95bcd97b85aceaf576db1b..4e7f2b9d19e6976772cb0dc2da69379bf41f0678 100644
--- a/py/parse.h
+++ b/py/parse.h
@@ -26,6 +26,10 @@
 #ifndef __MICROPY_INCLUDED_PY_PARSE_H__
 #define __MICROPY_INCLUDED_PY_PARSE_H__
 
+#include <stdint.h>
+
+#include "py/mpconfig.h"
+
 struct _mp_lexer_t;
 
 // a mp_parse_node_t is:
diff --git a/py/parsehelper.c b/py/parsehelper.c
index f304710673924f966245f8c8b8a32a2cd905df24..904268109be5b6e2b12380fdbf18b5adc2935361 100644
--- a/py/parsehelper.c
+++ b/py/parsehelper.c
@@ -26,16 +26,9 @@
 
 // these functions are separate from parse.c to keep parser independent of mp_obj_t
 
-#include <stdint.h>
 #include <stdio.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "lexer.h"
-#include "parse.h"
-#include "obj.h"
-#include "parsehelper.h"
+#include "py/parsehelper.h"
 
 #define STR_MEMORY "parser could not allocate enough memory"
 #define STR_UNEXPECTED_INDENT "unexpected indent"
diff --git a/py/parsehelper.h b/py/parsehelper.h
index 4a95f22fa2bde55fe5f2c0054d6dac813d8e6e67..1763809bad64812729ce6a68619e4eb23fd240db 100644
--- a/py/parsehelper.h
+++ b/py/parsehelper.h
@@ -28,6 +28,7 @@
 
 #include "py/lexer.h"
 #include "py/parse.h"
+#include "py/obj.h"
 
 void mp_parse_show_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind);
 mp_obj_t mp_parse_make_exception(mp_lexer_t *lex, mp_parse_error_kind_t parse_error_kind);
diff --git a/py/parsenum.c b/py/parsenum.c
index bb88eb729bb249a5b0ff638c9880369ca0d4256b..4706fef819eae1a568617086319819ff870c346f 100644
--- a/py/parsenum.c
+++ b/py/parsenum.c
@@ -27,15 +27,9 @@
 #include <stdbool.h>
 #include <stdlib.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "nlr.h"
-#include "obj.h"
-#include "parsenumbase.h"
-#include "parsenum.h"
-#include "smallint.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/parsenum.h"
+#include "py/smallint.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
 #include <math.h>
diff --git a/py/parsenum.h b/py/parsenum.h
index 5164d50016e56fb11d7d079c11b8a0cd6f4f850b..a769bdd8351d48c3501f097db95078dcf8690389 100644
--- a/py/parsenum.h
+++ b/py/parsenum.h
@@ -23,6 +23,14 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_PARSENUM_H__
+#define __MICROPY_INCLUDED_PY_PARSENUM_H__
 
+#include "py/mpconfig.h"
+#include "py/obj.h"
+
+mp_uint_t mp_parse_num_base(const char *str, mp_uint_t len, mp_uint_t *base);
 mp_obj_t mp_parse_num_integer(const char *restrict str, mp_uint_t len, mp_uint_t base);
 mp_obj_t mp_parse_num_decimal(const char *str, mp_uint_t len, bool allow_imag, bool force_complex);
+
+#endif // __MICROPY_INCLUDED_PY_PARSENUM_H__
diff --git a/py/parsenumbase.c b/py/parsenumbase.c
index f552c5e3787155d28c200ac14eb8fd77a5566ac3..5574b3b9b5c642fb48bba91e4f3b809b8af4b303 100644
--- a/py/parsenumbase.c
+++ b/py/parsenumbase.c
@@ -24,9 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "parsenumbase.h"
+#include "py/parsenum.h"
 
 // find real radix base, and strip preceding '0x', '0o' and '0b'
 // puts base in *base, and returns number of bytes to skip the prefix
diff --git a/py/parsenumbase.h b/py/parsenumbase.h
index 177f14451dd90fd00b09e05b06a6ea662dc820ea..f8953ec83553e2c08229cb02386e0d82006322b1 100644
--- a/py/parsenumbase.h
+++ b/py/parsenumbase.h
@@ -23,5 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_PARSENUM_H__
+#define __MICROPY_INCLUDED_PY_PARSENUM_H__
+
+#include "py/mpconfig.h"
 
 mp_uint_t mp_parse_num_base(const char *str, mp_uint_t len, mp_uint_t *base);
+
+#endif // __MICROPY_INCLUDED_PY_PARSENUM_H__
diff --git a/py/pfenv.c b/py/pfenv.c
index 965636aea0052a0fc3287409006a15666615c2fb..698f3b16cbda9b0bc048b30351b85a29425381f4 100644
--- a/py/pfenv.c
+++ b/py/pfenv.c
@@ -27,20 +27,15 @@
 #include <stdint.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "mpz.h"
-#include "objint.h"
-#include "pfenv.h"
+#include "py/objint.h"
+#include "py/pfenv.h"
 
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
 #include <stdio.h>
 #endif
 
 #if MICROPY_PY_BUILTINS_FLOAT
-#include "formatfloat.h"
+#include "py/formatfloat.h"
 #endif
 
 static const char pad_spaces[] = "                ";
@@ -331,7 +326,7 @@ int pfenv_print_float(const pfenv_t *pfenv, mp_float_t f, char fmt, int flags, c
     }
     int len;
 #if MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_FLOAT
-    len = format_float(f, buf, sizeof(buf), fmt, prec, sign);
+    len = mp_format_float(f, buf, sizeof(buf), fmt, prec, sign);
 #elif MICROPY_FLOAT_IMPL == MICROPY_FLOAT_IMPL_DOUBLE
     char fmt_buf[6];
     char *fmt_s = fmt_buf;
diff --git a/py/pfenv.h b/py/pfenv.h
index 98c1885f351e096661c2c77983c7285124eb159a..074c0012f81394aabecba6006210df8e3ded0181 100644
--- a/py/pfenv.h
+++ b/py/pfenv.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_PFENV_H__
+#define __MICROPY_INCLUDED_PY_PFENV_H__
+
+#include "py/obj.h"
 
 #define PF_FLAG_LEFT_ADJUST       (0x001)
 #define PF_FLAG_SHOW_SIGN         (0x002)
@@ -55,3 +59,5 @@ int pfenv_printf(const pfenv_t *pfenv, const char *fmt, ...);
 
 // Wrapper for system printf
 void printf_wrapper(void *env, const char *fmt, ...);
+
+#endif // __MICROPY_INCLUDED_PY_PFENV_H__
diff --git a/py/pfenv_printf.c b/py/pfenv_printf.c
index c0e826a5d2bbce6fb9182b97a30e2148869da54b..39bf321ce3fae471221eac93970fa049baea5bac 100644
--- a/py/pfenv_printf.c
+++ b/py/pfenv_printf.c
@@ -25,19 +25,13 @@
  */
 
 #include <assert.h>
-#include <stdio.h>
-#include <stdint.h>
 #include <string.h>
 #include <stdarg.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "pfenv.h"
+#include "py/pfenv.h"
 
 #if MICROPY_PY_BUILTINS_FLOAT
-#include "formatfloat.h"
+#include "py/formatfloat.h"
 #endif
 
 int pfenv_vprintf(const pfenv_t *pfenv, const char *fmt, va_list args) {
diff --git a/py/qstr.c b/py/qstr.c
index e08de2ebab70d41137647081afbdf693984ec3db..1bca8a10db887293e4f491d7799fd1722b967703 100644
--- a/py/qstr.c
+++ b/py/qstr.c
@@ -26,12 +26,9 @@
 
 #include <assert.h>
 #include <string.h>
-#include <stdint.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "gc.h"
+#include "py/qstr.h"
+#include "py/gc.h"
 
 // NOTE: we are using linear arrays to store and search for qstr's (unique strings, interned strings)
 // ultimately we will replace this with a static hash table of some kind
diff --git a/py/qstrdefs.h b/py/qstrdefs.h
index e91d36070339d005f4e309f39c4c6edaedf0f0a9..b8eacc68c7ff9a842a8c67f9c73d38e4dfa2c97f 100644
--- a/py/qstrdefs.h
+++ b/py/qstrdefs.h
@@ -24,7 +24,8 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
+#include "py/mpconfig.h"
+
 // All the qstr definitions in this file are available as constants.
 // That is, they are in ROM and you can reference them simply as MP_QSTR_xxxx.
 
diff --git a/py/repl.c b/py/repl.c
index 6bd880d92a2d2aa03a519154940dbae9c96f49ac..c6b3e60ae165a6a56e9d766feab04b66cd34d847 100644
--- a/py/repl.c
+++ b/py/repl.c
@@ -24,9 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "repl.h"
+#include "py/repl.h"
 
 #if MICROPY_HELPER_REPL
 
diff --git a/py/repl.h b/py/repl.h
index 92688f9f9a5b178fb03be26152ceede12fa8c352..db9256017603c333e937cfe6799dea9a8731e859 100644
--- a/py/repl.h
+++ b/py/repl.h
@@ -23,7 +23,14 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_REPL_H__
+#define __MICROPY_INCLUDED_PY_REPL_H__
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 #if MICROPY_HELPER_REPL
 bool mp_repl_continue_with_input(const char *input);
 #endif
+
+#endif // __MICROPY_INCLUDED_PY_REPL_H__
diff --git a/py/runtime.c b/py/runtime.c
index 505c8e31af6b2b4cbf43042bdbbd84ddc105272c..c4c73dfe4187539e8d90063d0382219d64278507 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -24,33 +24,24 @@
  * THE SOFTWARE.
  */
 
-#include <stdint.h>
 #include <stdio.h>
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objtuple.h"
-#include "objlist.h"
-#include "objmodule.h"
-#include "parsenum.h"
-#include "runtime0.h"
-#include "runtime.h"
-#include "emitglue.h"
-#include "builtin.h"
-#include "bc.h"
-#include "smallint.h"
-#include "objgenerator.h"
-#include "lexer.h"
-#include "parse.h"
-#include "parsehelper.h"
-#include "compile.h"
-#include "stackctrl.h"
-#include "gc.h"
+#include "py/nlr.h"
+#include "py/parsehelper.h"
+#include "py/parsenum.h"
+#include "py/compile.h"
+#include "py/objtuple.h"
+#include "py/objlist.h"
+#include "py/objmodule.h"
+#include "py/objgenerator.h"
+#include "py/smallint.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
+#include "py/builtin.h"
+#include "py/stackctrl.h"
+#include "py/gc.h"
 
 #if 0 // print debugging info
 #define DEBUG_PRINT (1)
diff --git a/py/scope.c b/py/scope.c
index 05606ffcced21ae075c266a2a4d0e9d0dc21d76d..4739ac3236fd0e5ab8906ed49296ae81c5f1ec98 100644
--- a/py/scope.c
+++ b/py/scope.c
@@ -24,17 +24,9 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
-#include <stdint.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "parse.h"
-#include "emitglue.h"
-#include "scope.h"
+#include "py/scope.h"
 
 scope_t *scope_new(scope_kind_t kind, mp_parse_node_t pn, qstr source_file, mp_uint_t emit_options) {
     scope_t *scope = m_new0(scope_t, 1);
diff --git a/py/scope.h b/py/scope.h
index 903a32a79a5a587a8f6258f7c285843107115660..6d74b17d28f4424417641687d6e49b4fe735597f 100644
--- a/py/scope.h
+++ b/py/scope.h
@@ -23,6 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_SCOPE_H__
+#define __MICROPY_INCLUDED_PY_SCOPE_H__
+
+#include "py/parse.h"
+#include "py/emitglue.h"
 
 enum {
     ID_INFO_KIND_GLOBAL_IMPLICIT,
@@ -77,3 +82,5 @@ id_info_t *scope_find_global(scope_t *scope, qstr qstr);
 id_info_t *scope_find_local_in_parent(scope_t *scope, qstr qstr);
 void scope_close_over_in_parents(scope_t *scope, qstr qstr);
 void scope_print_info(scope_t *s);
+
+#endif // __MICROPY_INCLUDED_PY_SCOPE_H__
diff --git a/py/sequence.c b/py/sequence.c
index 8cc7519be8cb26537467e692a6c0bb6d2d6fd6aa..0e76ccc027fdf7c13911cc6f16546f98751b2ac2 100644
--- a/py/sequence.c
+++ b/py/sequence.c
@@ -25,17 +25,12 @@
  * THE SOFTWARE.
  */
 
-#include <assert.h>
-#include <stdbool.h>
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime0.h"
-#include "runtime.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/runtime0.h"
+#include "py/runtime.h"
 
 // Helpers for sequence types
 
diff --git a/py/showbc.c b/py/showbc.c
index 4a765499cfb61fc242493eda17cd2bca0976157f..e2151c5a5c73ba93ea20ec307a9e9f924e0e3150 100644
--- a/py/showbc.c
+++ b/py/showbc.c
@@ -27,13 +27,9 @@
 #include <stdio.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "bc0.h"
-#include "bc.h"
+#include "py/bc0.h"
+#include "py/bc.h"
+
 extern const qstr mp_binary_op_method_name[];
 
 #if MICROPY_DEBUG_PRINTERS
diff --git a/py/smallint.c b/py/smallint.c
index 3a06c40a9f7e812e05f377bc380ab60dfb20e640..4c42ee0cc993158dcd82ce8dd5d6a96b2f42231a 100644
--- a/py/smallint.c
+++ b/py/smallint.c
@@ -24,11 +24,7 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "smallint.h"
+#include "py/smallint.h"
 
 bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y) {
     // Check for multiply overflow; see CERT INT32-C
diff --git a/py/smallint.h b/py/smallint.h
index 26a12874ef58dd02e2e57a1c882e99f8a410a442..980be42f3d681cfd507e8f734decdb169d032745 100644
--- a/py/smallint.h
+++ b/py/smallint.h
@@ -23,6 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_SMALLINT_H__
+#define __MICROPY_INCLUDED_PY_SMALLINT_H__
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 // Functions for small integer arithmetic
 
@@ -34,3 +39,5 @@
 bool mp_small_int_mul_overflow(mp_int_t x, mp_int_t y);
 mp_int_t mp_small_int_modulo(mp_int_t dividend, mp_int_t divisor);
 mp_int_t mp_small_int_floor_divide(mp_int_t num, mp_int_t denom);
+
+#endif // __MICROPY_INCLUDED_PY_SMALLINT_H__
diff --git a/py/stackctrl.c b/py/stackctrl.c
index 0ba43c28c7059fa836f8ea12ceb9af6dfb922e10..31336ec6998242e46d6446aabea291f84fdf0da7 100644
--- a/py/stackctrl.c
+++ b/py/stackctrl.c
@@ -24,13 +24,9 @@
  * THE SOFTWARE.
  */
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "nlr.h"
-#include "qstr.h"
-#include "obj.h"
-#include "runtime.h"
-#include "stackctrl.h"
+#include "py/nlr.h"
+#include "py/obj.h"
+#include "py/stackctrl.h"
 
 // Stack top at the start of program
 char *stack_top;
diff --git a/py/stackctrl.h b/py/stackctrl.h
index 4ed67774f88c9fcc04250dc1f518c0199baec8ff..bd18f21426c3a4d25d3e1f5e58d6839f2d83a605 100644
--- a/py/stackctrl.h
+++ b/py/stackctrl.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_STACKCTRL_H__
+#define __MICROPY_INCLUDED_PY_STACKCTRL_H__
+
+#include "py/mpconfig.h"
 
 void mp_stack_ctrl_init(void);
 mp_uint_t mp_stack_usage(void);
@@ -39,3 +43,5 @@ void mp_stack_check(void);
 #define MP_STACK_CHECK()
 
 #endif
+
+#endif // __MICROPY_INCLUDED_PY_STACKCTRL_H__
diff --git a/py/stream.c b/py/stream.c
index db7e5657fd0b745ed33b9be44cdb7ed18829b8e3..c57b7981aa4208b91be53e279460706781b6aea5 100644
--- a/py/stream.c
+++ b/py/stream.c
@@ -27,14 +27,10 @@
 
 #include <string.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "objstr.h"
-#include "runtime.h"
-#include "stream.h"
+#include "py/nlr.h"
+#include "py/objstr.h"
+#include "py/stream.h"
+
 #if MICROPY_STREAMS_NON_BLOCK
 #include <errno.h>
 #if defined(__MINGW32__) && !defined(__MINGW64_VERSION_MAJOR)
diff --git a/py/stream.h b/py/stream.h
index df71685353ceacf40f4e2487176349286afdce6a..f9c77aac6e5a5f4c58b068bd1faf7da0d5a72b70 100644
--- a/py/stream.h
+++ b/py/stream.h
@@ -23,6 +23,10 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_STREAM_H__
+#define __MICROPY_INCLUDED_PY_STREAM_H__
+
+#include "py/obj.h"
 
 MP_DECLARE_CONST_FUN_OBJ(mp_stream_read_obj);
 MP_DECLARE_CONST_FUN_OBJ(mp_stream_readinto_obj);
@@ -36,3 +40,5 @@ MP_DECLARE_CONST_FUN_OBJ(mp_stream_seek_obj);
 mp_obj_t mp_stream_unbuffered_iter(mp_obj_t self);
 
 mp_obj_t mp_stream_write(mp_obj_t self_in, const void *buf, mp_uint_t len);
+
+#endif // __MICROPY_INCLUDED_PY_STREAM_H__
diff --git a/py/unicode.c b/py/unicode.c
index 3951c2f8bbb757095678e16b751552dbeaf979dd..a83e3ac06adfdb69e4ad88bd0bda21cb99a3e42a 100644
--- a/py/unicode.c
+++ b/py/unicode.c
@@ -26,9 +26,7 @@
 
 #include <stdint.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "unicode.h"
+#include "py/unicode.h"
 
 // attribute flags
 #define FL_PRINT (0x01)
diff --git a/py/unicode.h b/py/unicode.h
index 283a7d044da2cff9fdc88f6af38e70be6bbbfeb3..89c28ed0ec0e4876868d50ceb51fd89afbbb0c07 100644
--- a/py/unicode.h
+++ b/py/unicode.h
@@ -1 +1,34 @@
+/*
+ * This file is part of the Micro Python project, http://micropython.org/
+ *
+ * The MIT License (MIT)
+ *
+ * Copyright (c) 2014 Damien P. George
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining a copy
+ * of this software and associated documentation files (the "Software"), to deal
+ * in the Software without restriction, including without limitation the rights
+ * to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
+ * copies of the Software, and to permit persons to whom the Software is
+ * furnished to do so, subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be included in
+ * all copies or substantial portions of the Software.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
+ * IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
+ * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
+ * AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
+ * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
+ * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
+ * THE SOFTWARE.
+ */
+#ifndef __MICROPY_INCLUDED_PY_UNICODE_H__
+#define __MICROPY_INCLUDED_PY_UNICODE_H__
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
+
 mp_uint_t utf8_ptr_to_index(const byte *s, const byte *ptr);
+
+#endif // __MICROPY_INCLUDED_PY_UNICODE_H__
diff --git a/py/vm.c b/py/vm.c
index b82a1eda57bf7816249d41bf0ba7fe28761a7652..b0f778352e88c73e9545e242ac160b9bf68e628d 100644
--- a/py/vm.c
+++ b/py/vm.c
@@ -29,16 +29,11 @@
 #include <string.h>
 #include <assert.h>
 
-#include "mpconfig.h"
-#include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "emitglue.h"
-#include "runtime.h"
-#include "bc0.h"
-#include "bc.h"
-#include "objgenerator.h"
+#include "py/nlr.h"
+#include "py/emitglue.h"
+#include "py/runtime.h"
+#include "py/bc0.h"
+#include "py/bc.h"
 
 #if 0
 #define TRACE(ip) printf("sp=" INT_FMT " ", sp - code_state->sp); mp_bytecode_print2(ip, 1);
@@ -110,7 +105,7 @@ mp_vm_return_kind_t mp_execute_bytecode(mp_code_state *code_state, volatile mp_o
 #define MARK_EXC_IP_GLOBAL() { code_state->ip = ip; } /* stores ip pointing to last opcode */
 #endif
 #if MICROPY_OPT_COMPUTED_GOTO
-    #include "vmentrytable.h"
+    #include "py/vmentrytable.h"
     #define DISPATCH() do { \
         TRACE(ip); \
         MARK_EXC_IP_GLOBAL(); \
diff --git a/py/vmentrytable.h b/py/vmentrytable.h
index d3de9758825f5f97c8fb3495c4d661049f57f8c3..2926c0d7cd67efe15f26afdceecc706dec629902 100644
--- a/py/vmentrytable.h
+++ b/py/vmentrytable.h
@@ -28,7 +28,7 @@
 #pragma clang diagnostic push
 #pragma clang diagnostic ignored "-Winitializer-overrides"
 #endif // __clang__
- 
+
 static void* entry_table[256] = {
     [0 ... 255] = &&entry_default,
     [MP_BC_LOAD_CONST_FALSE] = &&entry_MP_BC_LOAD_CONST_FALSE,
diff --git a/py/vstr.c b/py/vstr.c
index 03b03d0a30096c668c3be1d73537e21c7d3a196e..e87aef9e4862f196301fdc2dcf3250f6901c1d47 100644
--- a/py/vstr.c
+++ b/py/vstr.c
@@ -24,13 +24,13 @@
  * THE SOFTWARE.
  */
 
-#include <stdbool.h>
 #include <stdio.h>
 #include <stdarg.h>
 #include <string.h>
 #include <assert.h>
-#include "mpconfig.h"
-#include "misc.h"
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 // returned value is always at least 1 greater than argument
 #define ROUND_ALLOC(a) (((a) & ((~0) - 7)) + 8)
diff --git a/py/warning.c b/py/warning.c
index c7461c0f54d496d1a3481f38a6a80d252b48934f..4cce1776649ef4cecd54d355cf05eec5e0c349f8 100644
--- a/py/warning.c
+++ b/py/warning.c
@@ -23,17 +23,12 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
-#include <stdint.h>
+
 #include <stdarg.h>
 #include <stdio.h>
 
-#include "mpconfig.h"
-#include "misc.h"
-#include "qstr.h"
-#include "obj.h"
-#include "compile.h"
-#include "scope.h"
-#include "emit.h"
+#include "py/obj.h"
+#include "py/emit.h"
 
 #if MICROPY_WARNINGS
 
diff --git a/unix-cpy/main.c b/unix-cpy/main.c
index 81f39ed2798386295b3a4189fffcc07f277e8aca..002e26af8ce25f88f7d58a198e2c36c8379f0f94 100644
--- a/unix-cpy/main.c
+++ b/unix-cpy/main.c
@@ -34,7 +34,6 @@
 #include "misc.h"
 #include "qstr.h"
 #include "lexer.h"
-#include "lexerunix.h"
 #include "parse.h"
 #include "obj.h"
 #include "parsehelper.h"
diff --git a/unix/modsocket.c b/unix/modsocket.c
index f844d3b35553859d33798325b47558e977760954..402695d65b3d4cc369788365e407c02ec41afd43 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -44,7 +44,6 @@
 #include "qstr.h"
 #include "obj.h"
 #include "objtuple.h"
-#include "objarray.h"
 #include "objstr.h"
 #include "runtime.h"
 #include "stream.h"