diff --git a/esp8266/Makefile b/esp8266/Makefile
index 7efb0ca50dad0915d292c4edf808e093251415b0..5288e97d26a01fba33562634ec952665d4ba8f8c 100644
--- a/esp8266/Makefile
+++ b/esp8266/Makefile
@@ -11,6 +11,7 @@ CROSS_COMPILE = xtensa-lx106-elf-
 ESP_SDK = $(shell $(CC) -print-sysroot)/usr
 
 INC =  -I.
+INC += -I..
 INC += -I$(PY_SRC)
 INC += -I../stmhal
 INC += -I$(BUILD)
diff --git a/py/misc.h b/py/misc.h
index 2f53dcbd3d56c580ea5cb30b223deba71c70a346..c0fd293de53bfd22d5eaa75bd9aaa140d0755dac 100644
--- a/py/misc.h
+++ b/py/misc.h
@@ -23,12 +23,11 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_MISC_H__
+#define __MICROPY_INCLUDED_PY_MISC_H__
 
 // a mini library of useful types and functions
 
-#ifndef _INCLUDED_MINILIB_H
-#define _INCLUDED_MINILIB_H
-
 /** types *******************************************************/
 
 #include <stdbool.h>
@@ -185,4 +184,4 @@ static inline mp_uint_t count_lead_ones(byte val) {
 }
 #endif
 
-#endif // _INCLUDED_MINILIB_H
+#endif // __MICROPY_INCLUDED_PY_MISC_H__
diff --git a/py/mpconfig.h b/py/mpconfig.h
index 76f31e48e91430d5f36ab0b918772c644498af2a..b193051c51d3ee617bd77250a381058abfdf3d7e 100644
--- a/py/mpconfig.h
+++ b/py/mpconfig.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_MPCONFIG_H__
+#define __MICROPY_INCLUDED_PY_MPCONFIG_H__
 
 // This file contains default configuration settings for MicroPython.
 // You can override any of the options below using mpconfigport.h file
@@ -572,3 +574,5 @@ typedef double mp_float_t;
 #ifndef MP_UNLIKELY
 #define MP_UNLIKELY(x) __builtin_expect((x), 0)
 #endif
+
+#endif // __MICROPY_INCLUDED_PY_MPCONFIG_H__
diff --git a/py/obj.h b/py/obj.h
index c37c4d3fa6a00306136ea32f8d074f34a665c5be..bd4cd31aa08c3938910f32350d032460a0a17471 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -23,6 +23,12 @@
  * OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
  * THE SOFTWARE.
  */
+#ifndef __MICROPY_INCLUDED_PY_OBJ_H__
+#define __MICROPY_INCLUDED_PY_OBJ_H__
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
+#include "py/qstr.h"
 
 // A Micro Python object is a machine word having the following form:
 //  - xxxx...xxx1 : a small int, bits 1 and above are the value
@@ -81,7 +87,7 @@ typedef struct _mp_obj_base_t mp_obj_base_t;
 #define MP_OBJ_NEW_SMALL_INT(small_int) ((mp_obj_t)((((mp_int_t)(small_int)) << 1) | 1))
 
 #define MP_OBJ_QSTR_VALUE(o) (((mp_int_t)(o)) >> 2)
-#define MP_OBJ_NEW_QSTR(qstr) ((mp_obj_t)((((mp_uint_t)(qstr)) << 2) | 2))
+#define MP_OBJ_NEW_QSTR(qst) ((mp_obj_t)((((mp_uint_t)(qst)) << 2) | 2))
 
 // These macros are used to declare and define constant function objects
 // You can put "static" in front of the definitions to make them local
@@ -620,3 +626,5 @@ mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice
     /*printf("memmove(%p, %p, %d)\n", dest + beg + len_adj, dest + beg, (dest_len - beg) * sizeof(item_t));*/ \
     memmove(dest + beg + len_adj, dest + beg, (dest_len - beg) * sizeof(item_t)); \
     memcpy(dest + beg, slice, slice_len * sizeof(item_t));
+
+#endif // __MICROPY_INCLUDED_PY_OBJ_H__
diff --git a/py/parsehelper.h b/py/parsehelper.h
index 676837f53eb86902b4e94bb681b57f6dd58b7faf..4a95f22fa2bde55fe5f2c0054d6dac813d8e6e67 100644
--- a/py/parsehelper.h
+++ b/py/parsehelper.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_PARSEHELPER_H__
+#define __MICROPY_INCLUDED_PY_PARSEHELPER_H__
+
+#include "py/lexer.h"
+#include "py/parse.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);
+
+#endif // __MICROPY_INCLUDED_PY_PARSEHELPER_H__
diff --git a/py/qstr.h b/py/qstr.h
index aa4ed416105cf7b68505b2fdd216cbf6f539925f..a383452b844f8d49611a3139ae8f0eeef1b6e929 100644
--- a/py/qstr.h
+++ b/py/qstr.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_QSTR_H__
+#define __MICROPY_INCLUDED_PY_QSTR_H__
+
+#include "py/mpconfig.h"
+#include "py/misc.h"
 
 // See qstrdefs.h for a list of qstr's that are available as constants.
 // Reference them as MP_QSTR_xxxx.
@@ -60,3 +65,5 @@ mp_uint_t qstr_len(qstr q);
 const byte* qstr_data(qstr q, mp_uint_t *len);
 
 void qstr_pool_info(mp_uint_t *n_pool, mp_uint_t *n_qstr, mp_uint_t *n_str_data_bytes, mp_uint_t *n_total_bytes);
+
+#endif // __MICROPY_INCLUDED_PY_QSTR_H__
diff --git a/py/runtime.h b/py/runtime.h
index 5fbec5937f2a2ee597569d17e7282bcb95bf527b..54cc60c19cd12b5011f732b0a53ebf9e69963a6b 100644
--- a/py/runtime.h
+++ b/py/runtime.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_RUNTIME_H__
+#define __MICROPY_INCLUDED_PY_RUNTIME_H__
+
+#include "py/obj.h"
 
 typedef enum {
     MP_VM_RETURN_NORMAL,
@@ -120,3 +124,5 @@ extern struct _mp_obj_list_t mp_sys_path_obj;
 extern struct _mp_obj_list_t mp_sys_argv_obj;
 #define mp_sys_path ((mp_obj_t)&mp_sys_path_obj)
 #define mp_sys_argv ((mp_obj_t)&mp_sys_argv_obj)
+
+#endif // __MICROPY_INCLUDED_PY_RUNTIME_H__
diff --git a/stmhal/pyexec.c b/stmhal/pyexec.c
index cae87591b11b2f638529bc88a40c6ca45c0c3dda..f1e645447ce4506e22b8436a0fb1e3a4d5958ece 100644
--- a/stmhal/pyexec.c
+++ b/stmhal/pyexec.c
@@ -30,11 +30,6 @@
 
 #include "mpconfig.h"
 #include "nlr.h"
-#include "misc.h"
-#include "qstr.h"
-#include "misc.h"
-#include "lexer.h"
-#include "parse.h"
 #include "obj.h"
 #include "parsehelper.h"
 #include "compile.h"
diff --git a/unix/main.c b/unix/main.c
index a0396e51785693b6554e5f896a7c7f21ff7c6328..d3ab53da6ea9a901d7ee1239ae34122576520629 100644
--- a/unix/main.c
+++ b/unix/main.c
@@ -37,11 +37,6 @@
 
 #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 "parsehelper.h"
 #include "compile.h"