diff --git a/py/builtin.c b/py/builtin.c
index 4fea1fdb2105279d825cc8573fc6aedfb66da8b3..c92dcbb7135c2787e7f630a354da11eb7ddfef0e 100644
--- a/py/builtin.c
+++ b/py/builtin.c
@@ -46,7 +46,7 @@
 // args[0] is function from class body
 // args[1] is class name
 // args[2:] are base objects
-STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin___build_class__(mp_uint_t n_args, const mp_obj_t *args) {
     assert(2 <= n_args);
 
     // set the new classes __locals__ object
@@ -86,7 +86,6 @@ STATIC mp_obj_t mp_builtin___build_class__(uint n_args, const mp_obj_t *args) {
 
     return new_class;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR(mp_builtin___build_class___obj, 2, mp_builtin___build_class__);
 
 STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
@@ -96,7 +95,6 @@ STATIC mp_obj_t mp_builtin___repl_print__(mp_obj_t o) {
     }
     return mp_const_none;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin___repl_print___obj, mp_builtin___repl_print__);
 
 STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
@@ -127,7 +125,6 @@ STATIC mp_obj_t mp_builtin_abs(mp_obj_t o_in) {
         return mp_const_none;
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_abs_obj, mp_builtin_abs);
 
 STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
@@ -140,7 +137,6 @@ STATIC mp_obj_t mp_builtin_all(mp_obj_t o_in) {
     }
     return mp_const_true;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_all_obj, mp_builtin_all);
 
 STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
@@ -153,14 +149,12 @@ STATIC mp_obj_t mp_builtin_any(mp_obj_t o_in) {
     }
     return mp_const_false;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_any_obj, mp_builtin_any);
 
 STATIC mp_obj_t mp_builtin_bin(mp_obj_t o_in) {
     mp_obj_t args[] = { MP_OBJ_NEW_QSTR(MP_QSTR__brace_open__colon__hash_b_brace_close_), o_in };
     return mp_obj_str_format(MP_ARRAY_SIZE(args), args);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_bin_obj, mp_builtin_bin);
 
 STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
@@ -170,7 +164,6 @@ STATIC mp_obj_t mp_builtin_callable(mp_obj_t o_in) {
         return mp_const_false;
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_callable_obj, mp_builtin_callable);
 
 STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
@@ -209,10 +202,9 @@ STATIC mp_obj_t mp_builtin_chr(mp_obj_t o_in) {
     }
     #endif
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_chr_obj, mp_builtin_chr);
 
-STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_dir(mp_uint_t n_args, const mp_obj_t *args) {
     // TODO make this function more general and less of a hack
 
     mp_obj_dict_t *dict = NULL;
@@ -238,7 +230,7 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
 
     mp_obj_t dir = mp_obj_new_list(0, NULL);
     if (dict != NULL) {
-        for (uint i = 0; i < dict->map.alloc; i++) {
+        for (mp_uint_t i = 0; i < dict->map.alloc; i++) {
             if (MP_MAP_SLOT_IS_FILLED(&dict->map, i)) {
                 mp_obj_list_append(dir, dict->map.table[i].key);
             }
@@ -247,7 +239,6 @@ STATIC mp_obj_t mp_builtin_dir(uint n_args, const mp_obj_t *args) {
 
     return dir;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_dir_obj, 0, 1, mp_builtin_dir);
 
 STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
@@ -262,29 +253,25 @@ STATIC mp_obj_t mp_builtin_divmod(mp_obj_t o1_in, mp_obj_t o2_in) {
         nlr_raise(mp_obj_new_exception_msg_varg(&mp_type_TypeError, "unsupported operand type(s) for divmod(): '%s' and '%s'", mp_obj_get_type_str(o1_in), mp_obj_get_type_str(o2_in)));
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_divmod_obj, mp_builtin_divmod);
 
 STATIC mp_obj_t mp_builtin_hash(mp_obj_t o_in) {
     // TODO hash will generally overflow small integer; can we safely truncate it?
     return mp_obj_new_int(mp_obj_hash(o_in));
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hash_obj, mp_builtin_hash);
 
 STATIC mp_obj_t mp_builtin_hex(mp_obj_t o_in) {
     return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_x), o_in);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_hex_obj, mp_builtin_hex);
 
 STATIC mp_obj_t mp_builtin_iter(mp_obj_t o_in) {
     return mp_getiter(o_in);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_iter_obj, mp_builtin_iter);
 
-STATIC mp_obj_t mp_builtin_min_max(uint n_args, const mp_obj_t *args, mp_map_t *kwargs, int op) {
+STATIC mp_obj_t mp_builtin_min_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs, mp_uint_t op) {
     mp_map_elem_t *key_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_key), MP_MAP_LOOKUP);
     mp_obj_t key_fn = key_elem == NULL ? MP_OBJ_NULL : key_elem->value;
     if (n_args == 1) {
@@ -319,12 +306,12 @@ STATIC mp_obj_t mp_builtin_min_max(uint n_args, const mp_obj_t *args, mp_map_t *
     }
 }
 
-STATIC mp_obj_t mp_builtin_max(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_max(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_MORE);
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_max_obj, 1, mp_builtin_max);
 
-STATIC mp_obj_t mp_builtin_min(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_min(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     return mp_builtin_min_max(n_args, args, kwargs, MP_BINARY_OP_LESS);
 }
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_min_obj, 1, mp_builtin_min);
@@ -337,17 +324,15 @@ STATIC mp_obj_t mp_builtin_next(mp_obj_t o) {
         return ret;
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_next_obj, mp_builtin_next);
 
 STATIC mp_obj_t mp_builtin_oct(mp_obj_t o_in) {
     return mp_binary_op(MP_BINARY_OP_MODULO, MP_OBJ_NEW_QSTR(MP_QSTR__percent__hash_o), o_in);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_oct_obj, mp_builtin_oct);
 
 STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
-    uint len;
+    mp_uint_t len;
     const char *str = mp_obj_str_get_data(o_in, &len);
     #if MICROPY_PY_BUILTINS_STR_UNICODE
     mp_uint_t charlen = unichar_charlen(str, len);
@@ -376,26 +361,24 @@ STATIC mp_obj_t mp_builtin_ord(mp_obj_t o_in) {
     }
     #endif
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_ord_obj, mp_builtin_ord);
 
-STATIC mp_obj_t mp_builtin_pow(uint n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_pow(mp_uint_t n_args, const mp_obj_t *args) {
     assert(2 <= n_args && n_args <= 3);
     switch (n_args) {
         case 2: return mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]);
         default: return mp_binary_op(MP_BINARY_OP_MODULO, mp_binary_op(MP_BINARY_OP_POWER, args[0], args[1]), args[2]); // TODO optimise...
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_pow_obj, 2, 3, mp_builtin_pow);
 
-STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_print(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     mp_map_elem_t *sep_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_sep), MP_MAP_LOOKUP);
     mp_map_elem_t *end_elem = mp_map_lookup(kwargs, MP_OBJ_NEW_QSTR(MP_QSTR_end), MP_MAP_LOOKUP);
     const char *sep_data = " ";
-    uint sep_len = 1;
+    mp_uint_t sep_len = 1;
     const char *end_data = "\n";
-    uint end_len = 1;
+    mp_uint_t end_len = 1;
     if (sep_elem != NULL && sep_elem->value != mp_const_none) {
         sep_data = mp_obj_str_get_data(sep_elem->value, &sep_len);
     }
@@ -434,7 +417,6 @@ STATIC mp_obj_t mp_builtin_print(uint n_args, const mp_obj_t *args, mp_map_t *kw
     #endif
     return mp_const_none;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_print_obj, 0, mp_builtin_print);
 
 STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
@@ -447,7 +429,7 @@ STATIC mp_obj_t mp_builtin_repr(mp_obj_t o_in) {
 
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_repr_obj, mp_builtin_repr);
 
-STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_sum(mp_uint_t n_args, const mp_obj_t *args) {
     assert(1 <= n_args && n_args <= 2);
     mp_obj_t value;
     switch (n_args) {
@@ -461,10 +443,9 @@ STATIC mp_obj_t mp_builtin_sum(uint n_args, const mp_obj_t *args) {
     }
     return value;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_sum_obj, 1, 2, mp_builtin_sum);
 
-STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *kwargs) {
+STATIC mp_obj_t mp_builtin_sorted(mp_uint_t n_args, const mp_obj_t *args, mp_map_t *kwargs) {
     assert(n_args >= 1);
     if (n_args > 1) {
         nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError,
@@ -475,7 +456,6 @@ STATIC mp_obj_t mp_builtin_sorted(uint n_args, const mp_obj_t *args, mp_map_t *k
 
     return self;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_KW(mp_builtin_sorted_obj, 1, mp_builtin_sorted);
 
 STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
@@ -495,7 +475,6 @@ STATIC mp_obj_t mp_builtin_id(mp_obj_t o_in) {
         return mp_obj_new_int_from_uint((mp_uint_t)id);
     }
 }
-
 MP_DEFINE_CONST_FUN_OBJ_1(mp_builtin_id_obj, mp_builtin_id);
 
 // See mp_load_attr() if making any changes
@@ -514,7 +493,7 @@ STATIC inline mp_obj_t mp_load_attr_default(mp_obj_t base, qstr attr, mp_obj_t d
     }
 }
 
-STATIC mp_obj_t mp_builtin_getattr(uint n_args, const mp_obj_t *args) {
+STATIC mp_obj_t mp_builtin_getattr(mp_uint_t n_args, const mp_obj_t *args) {
     mp_obj_t attr = args[1];
     if (MP_OBJ_IS_TYPE(attr, &mp_type_str)) {
         attr = mp_obj_str_intern(attr);
@@ -527,7 +506,6 @@ STATIC mp_obj_t mp_builtin_getattr(uint n_args, const mp_obj_t *args) {
     }
     return mp_load_attr_default(args[0], MP_OBJ_QSTR_VALUE(attr), defval);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin_getattr_obj, 2, 3, mp_builtin_getattr);
 
 STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
@@ -542,7 +520,6 @@ STATIC mp_obj_t mp_builtin_hasattr(mp_obj_t object_in, mp_obj_t attr_in) {
 
     return MP_BOOL(dest[0] != MP_OBJ_NULL);
 }
-
 MP_DEFINE_CONST_FUN_OBJ_2(mp_builtin_hasattr_obj, mp_builtin_hasattr);
 
 // These are defined in terms of MicroPython API functions right away
diff --git a/py/builtinevex.c b/py/builtinevex.c
index 3b7fb16f871ab6e3287fb9b1842bf8e6bc8b25e5..6faeb6a07161a4a4227c1a4b6ec32784d9eb9ba1 100644
--- a/py/builtinevex.c
+++ b/py/builtinevex.c
@@ -41,7 +41,7 @@
 #include "builtin.h"
 
 STATIC mp_obj_t parse_compile_execute(mp_obj_t o_in, mp_parse_input_kind_t parse_input_kind) {
-    uint str_len;
+    mp_uint_t str_len;
     const char *str = mp_obj_str_get_data(o_in, &str_len);
 
     // create the lexer
diff --git a/py/builtinimport.c b/py/builtinimport.c
index fad9567966953a2f32660eda5f5b4d6968369ae1..fa3bcde6538657f05d4fd48e2bab48a6019bbd5b 100644
--- a/py/builtinimport.c
+++ b/py/builtinimport.c
@@ -84,7 +84,7 @@ STATIC mp_import_stat_t find_file(const char *file_str, uint file_len, vstr_t *d
         // go through each path looking for a directory or file
         for (int i = 0; i < path_num; i++) {
             vstr_reset(dest);
-            uint p_len;
+            mp_uint_t p_len;
             const char *p = mp_obj_str_get_data(path_items[i], &p_len);
             if (p_len > 0) {
                 vstr_add_strn(dest, p, p_len);
@@ -185,8 +185,8 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
         }
     }
 
-    uint mod_len;
-    const char *mod_str = (const char*)mp_obj_str_get_data(module_name, &mod_len);
+    mp_uint_t mod_len;
+    const char *mod_str = mp_obj_str_get_data(module_name, &mod_len);
 
     if (level != 0) {
         // What we want to do here is to take name of current module,
@@ -204,8 +204,8 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
         printf("\n");
 #endif
 
-        uint this_name_l;
-        const char *this_name = (const char*)mp_obj_str_get_data(this_name_q, &this_name_l);
+        mp_uint_t this_name_l;
+        const char *this_name = mp_obj_str_get_data(this_name_q, &this_name_l);
 
         uint dots_seen = 0;
         const char *p = this_name + this_name_l - 1;
@@ -353,5 +353,4 @@ mp_obj_t mp_builtin___import__(uint n_args, mp_obj_t *args) {
     // Otherwise, we need to return top-level package
     return top_module_obj;
 }
-
 MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mp_builtin___import___obj, 1, 5, mp_builtin___import__);
diff --git a/py/obj.h b/py/obj.h
index 33899341dac5955d52903a6db3147414ba07d6fa..b7ae74ec72e74f1794bd8f428fe5842844f23414 100644
--- a/py/obj.h
+++ b/py/obj.h
@@ -365,17 +365,17 @@ mp_obj_t mp_obj_new_bool(bool value);
 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, uint len, bool neg, uint base);
+mp_obj_t mp_obj_new_int_from_str_len(const char **str, mp_uint_t len, bool neg, mp_uint_t 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_str(const char* data, uint len, bool make_qstr_if_not_already);
-mp_obj_t mp_obj_new_bytes(const byte* data, uint len);
+mp_obj_t mp_obj_new_str(const char* data, mp_uint_t len, bool make_qstr_if_not_already);
+mp_obj_t mp_obj_new_bytes(const byte* data, mp_uint_t len);
 #if MICROPY_PY_BUILTINS_FLOAT
 mp_obj_t mp_obj_new_float(mp_float_t val);
 mp_obj_t mp_obj_new_complex(mp_float_t real, mp_float_t imag);
 #endif
 mp_obj_t mp_obj_new_exception(const mp_obj_type_t *exc_type);
 mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg);
-mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args);
+mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, mp_uint_t n_args, const mp_obj_t *args);
 mp_obj_t mp_obj_new_exception_msg(const mp_obj_type_t *exc_type, const char *msg);
 mp_obj_t mp_obj_new_exception_msg_varg(const mp_obj_type_t *exc_type, const char *fmt, ...); // counts args by number of % symbols in fmt, excluding %%; can only handle void* sizes (ie no float/double!)
 mp_obj_t mp_obj_new_fun_bc(mp_uint_t scope_flags, qstr *args, mp_uint_t n_pos_args, mp_uint_t n_kwonly_args, mp_obj_t def_args, mp_obj_t def_kw_args, const byte *code);
@@ -383,7 +383,7 @@ mp_obj_t mp_obj_new_fun_native(mp_uint_t n_args, void *fun_data);
 mp_obj_t mp_obj_new_fun_viper(mp_uint_t n_args, void *fun_data, mp_uint_t type_sig);
 mp_obj_t mp_obj_new_fun_asm(mp_uint_t n_args, void *fun_data);
 mp_obj_t mp_obj_new_gen_wrap(mp_obj_t fun);
-mp_obj_t mp_obj_new_closure(mp_obj_t fun, uint n_closed, const mp_obj_t *closed);
+mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed, const mp_obj_t *closed);
 mp_obj_t mp_obj_new_tuple(mp_uint_t n, const mp_obj_t *items);
 mp_obj_t mp_obj_new_list(mp_uint_t n, mp_obj_t *items);
 mp_obj_t mp_obj_new_dict(mp_uint_t n_args);
@@ -463,17 +463,17 @@ mp_obj_t mp_alloc_emergency_exception_buf(mp_obj_t size_in);
 void mp_init_emergency_exception_buf(void);
 
 // str
-mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, uint len, byte **data);
+mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, mp_uint_t len, byte **data);
 mp_obj_t mp_obj_str_builder_end(mp_obj_t o_in);
 mp_obj_t mp_obj_str_builder_end_with_len(mp_obj_t o_in, mp_uint_t len);
 bool mp_obj_str_equal(mp_obj_t s1, mp_obj_t s2);
-uint mp_obj_str_get_hash(mp_obj_t self_in);
-uint mp_obj_str_get_len(mp_obj_t self_in);
+mp_uint_t mp_obj_str_get_hash(mp_obj_t self_in);
+mp_uint_t mp_obj_str_get_len(mp_obj_t self_in);
 qstr mp_obj_str_get_qstr(mp_obj_t self_in); // use this if you will anyway convert the string to a qstr
 const char *mp_obj_str_get_str(mp_obj_t self_in); // use this only if you need the string to be null terminated
-const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len);
+const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len);
 mp_obj_t mp_obj_str_intern(mp_obj_t str);
-void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, uint str_len, bool is_bytes);
+void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env, const byte *str_data, mp_uint_t str_len, bool is_bytes);
 
 #if MICROPY_PY_BUILTINS_FLOAT
 // float
@@ -522,8 +522,8 @@ void mp_obj_set_store(mp_obj_t self_in, mp_obj_t item);
 void mp_obj_slice_get(mp_obj_t self_in, mp_obj_t *start, mp_obj_t *stop, mp_obj_t *step);
 
 // array
-uint mp_obj_array_len(mp_obj_t self_in);
-mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items);
+mp_uint_t mp_obj_array_len(mp_obj_t self_in);
+mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items);
 
 // functions
 #define MP_OBJ_FUN_ARGS_MAX (0xffff) // to set maximum value in n_args_max below
@@ -569,17 +569,17 @@ typedef struct {
     mp_int_t step;
 } mp_bound_slice_t;
 
-void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest);
+void mp_seq_multiply(const void *items, mp_uint_t item_sz, mp_uint_t len, mp_uint_t times, void *dest);
 #if MICROPY_PY_BUILTINS_SLICE
 bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice_t *indexes);
 #endif
 #define mp_seq_copy(dest, src, len, item_t) memcpy(dest, src, len * sizeof(item_t))
 #define mp_seq_cat(dest, src1, len1, src2, len2, item_t) { memcpy(dest, src1, (len1) * sizeof(item_t)); memcpy(dest + (len1), src2, (len2) * sizeof(item_t)); }
-bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2);
-bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2);
-mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args);
-mp_obj_t mp_seq_count_obj(const mp_obj_t *items, uint len, mp_obj_t value);
-mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *indexes);
+bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *data2, mp_uint_t len2);
+bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, mp_uint_t len1, const mp_obj_t *items2, mp_uint_t len2);
+mp_obj_t mp_seq_index_obj(const mp_obj_t *items, mp_uint_t len, mp_uint_t n_args, const mp_obj_t *args);
+mp_obj_t mp_seq_count_obj(const mp_obj_t *items, mp_uint_t len, mp_obj_t value);
+mp_obj_t mp_seq_extract_slice(mp_uint_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_replace_slice_no_grow(dest, dest_len, beg, end, slice, slice_len, item_t) \
diff --git a/py/objarray.c b/py/objarray.c
index 4930b183220198af16da766bda987db0a7b499bb..6a3e862baae88694bed39b50175f9db065d8d90c 100644
--- a/py/objarray.c
+++ b/py/objarray.c
@@ -108,7 +108,7 @@ STATIC mp_obj_t array_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
     mp_arg_check_num(n_args, n_kw, 1, 2, false);
 
     // get typecode
-    uint l;
+    mp_uint_t l;
     const char *typecode = mp_obj_str_get_data(args[0], &l);
 
     if (n_args == 1) {
@@ -277,7 +277,7 @@ STATIC mp_obj_array_t *array_new(char typecode, uint n) {
     return o;
 }
 
-uint mp_obj_array_len(mp_obj_t self_in) {
+mp_uint_t mp_obj_array_len(mp_obj_t self_in) {
     return ((mp_obj_array_t *)self_in)->len;
 }
 
@@ -288,7 +288,7 @@ mp_obj_t mp_obj_new_bytearray(uint n, void *items) {
 }
 
 // Create bytearray which references specified memory area
-mp_obj_t mp_obj_new_bytearray_by_ref(uint n, void *items) {
+mp_obj_t mp_obj_new_bytearray_by_ref(mp_uint_t n, void *items) {
     mp_obj_array_t *o = m_new_obj(mp_obj_array_t);
     o->base.type = &mp_type_array;
     o->typecode = BYTEARRAY_TYPECODE;
diff --git a/py/objclosure.c b/py/objclosure.c
index b5456b173022538b42b82f7fb7b93403a3202c62..c7d72d4b3eaf1cd427a022a776b7e4232eba9552 100644
--- a/py/objclosure.c
+++ b/py/objclosure.c
@@ -89,7 +89,7 @@ const mp_obj_type_t closure_type = {
     .call = closure_call,
 };
 
-mp_obj_t mp_obj_new_closure(mp_obj_t fun, uint n_closed_over, const mp_obj_t *closed) {
+mp_obj_t mp_obj_new_closure(mp_obj_t fun, mp_uint_t n_closed_over, const mp_obj_t *closed) {
     mp_obj_closure_t *o = m_new_obj_var(mp_obj_closure_t, mp_obj_t, n_closed_over);
     o->base.type = &closure_type;
     o->fun = fun;
diff --git a/py/objcomplex.c b/py/objcomplex.c
index 7876068c070f97d33e1034bbf8e93d915c9620ac..8e0f638c3e3660c5af4000cef77678a2d27838cb 100644
--- a/py/objcomplex.c
+++ b/py/objcomplex.c
@@ -84,7 +84,7 @@ STATIC mp_obj_t complex_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n
         case 1:
             if (MP_OBJ_IS_STR(args[0])) {
                 // a string, parse it
-                uint l;
+                mp_uint_t l;
                 const char *s = mp_obj_str_get_data(args[0], &l);
                 return mp_parse_num_decimal(s, l, true, true);
             } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_complex)) {
diff --git a/py/objexcept.c b/py/objexcept.c
index 606429191d25c07a0f05e2e8936fd3648b579d48..6cf9cbc4b5acbe5b86b731b245329d3c3c8e380b 100644
--- a/py/objexcept.c
+++ b/py/objexcept.c
@@ -296,7 +296,7 @@ mp_obj_t mp_obj_new_exception_arg1(const mp_obj_type_t *exc_type, mp_obj_t arg)
     return mp_obj_new_exception_args(exc_type, 1, &arg);
 }
 
-mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, uint n_args, const mp_obj_t *args) {
+mp_obj_t mp_obj_new_exception_args(const mp_obj_type_t *exc_type, mp_uint_t n_args, const mp_obj_t *args) {
     assert(exc_type->make_new == mp_obj_exception_make_new);
     return exc_type->make_new((mp_obj_t)exc_type, n_args, 0, args);
 }
diff --git a/py/objfloat.c b/py/objfloat.c
index 1c55106fd95e2e3ccb934fa4e45370d262d2563b..52d484135fbb9292a6e48e026dde54427cf6c7c1 100644
--- a/py/objfloat.c
+++ b/py/objfloat.c
@@ -77,7 +77,7 @@ STATIC mp_obj_t float_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_k
         default:
             if (MP_OBJ_IS_STR(args[0])) {
                 // a string, parse it
-                uint l;
+                mp_uint_t l;
                 const char *s = mp_obj_str_get_data(args[0], &l);
                 return mp_parse_num_decimal(s, l, false, false);
             } else if (MP_OBJ_IS_TYPE(args[0], &mp_type_float)) {
diff --git a/py/objint.c b/py/objint.c
index 16e868a37bdd7e48859b6af49e1777f5ff62d43c..9030d71c30fa8e929e2f7ba873720fdc4741a698 100644
--- a/py/objint.c
+++ b/py/objint.c
@@ -60,7 +60,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
                 return args[0];
             } else if (MP_OBJ_IS_STR_OR_BYTES(args[0])) {
                 // a string, parse it
-                uint l;
+                mp_uint_t l;
                 const char *s = mp_obj_str_get_data(args[0], &l);
                 return mp_parse_num_integer(s, l, 0);
 #if MICROPY_PY_BUILTINS_FLOAT
@@ -76,7 +76,7 @@ STATIC mp_obj_t mp_obj_int_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_
         default: {
             // should be a string, parse it
             // TODO proper error checking of argument types
-            uint l;
+            mp_uint_t l;
             const char *s = mp_obj_str_get_data(args[0], &l);
             return mp_parse_num_integer(s, l, mp_obj_get_int(args[1]));
         }
diff --git a/py/objint_mpz.c b/py/objint_mpz.c
index 6e347c7425f4f7ae8f4db5683114b505b07b7b00..05227368bfbf50c435c59faece27508e23ad88b9 100644
--- a/py/objint_mpz.c
+++ b/py/objint_mpz.c
@@ -290,9 +290,9 @@ mp_obj_t mp_obj_new_int_from_uint(mp_uint_t value) {
     return mp_obj_new_int_from_ll(value);
 }
 
-mp_obj_t mp_obj_new_int_from_str_len(const char **str, uint len, bool neg, uint base) {
+mp_obj_t mp_obj_new_int_from_str_len(const char **str, mp_uint_t len, bool neg, mp_uint_t base) {
     mp_obj_int_t *o = mp_obj_int_new_mpz();
-    uint n = mpz_set_from_str(&o->mpz, *str, len, neg, base);
+    mp_uint_t n = mpz_set_from_str(&o->mpz, *str, len, neg, base);
     *str += n;
     return o;
 }
diff --git a/py/objstr.c b/py/objstr.c
index d1670b5796942d5a89d1c1900429be105e2de074..d32ba9ac3dfedafce0e51fef81820fedef7f876f 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -53,7 +53,7 @@ STATIC NORETURN void arg_type_mixup();
 /* str                                                                        */
 
 void mp_str_print_quoted(void (*print)(void *env, const char *fmt, ...), void *env,
-                         const byte *str_data, uint str_len, bool is_bytes) {
+                         const byte *str_data, mp_uint_t str_len, bool is_bytes) {
     // this escapes characters, but it will be very slow to print (calling print many times)
     bool has_single_quote = false;
     bool has_double_quote = false;
@@ -483,7 +483,7 @@ STATIC mp_obj_t str_split(mp_uint_t n_args, const mp_obj_t *args) {
             arg_type_mixup();
         }
 
-        uint sep_len;
+        mp_uint_t sep_len;
         const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
 
         if (sep_len == 0) {
@@ -535,7 +535,7 @@ STATIC mp_obj_t str_rsplit(mp_uint_t n_args, const mp_obj_t *args) {
     if (sep == mp_const_none) {
         assert(!"TODO: rsplit(None,n) not implemented");
     } else {
-        uint sep_len;
+        mp_uint_t sep_len;
         const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
 
         if (sep_len == 0) {
@@ -1121,9 +1121,8 @@ mp_obj_t mp_obj_str_format(mp_uint_t n_args, const mp_obj_t *args) {
                     mp_obj_print_helper((void (*)(void*, const char*, ...))vstr_printf, vstr, arg, PRINT_STR);
                     break;
 
-                case 's':
-                {
-                    uint len;
+                case 's': {
+                    mp_uint_t len;
                     const char *s = mp_obj_str_get_data(arg, &len);
                     if (precision < 0) {
                         precision = len;
@@ -1249,7 +1248,7 @@ not_enough_args:
         switch (*str) {
             case 'c':
                 if (MP_OBJ_IS_STR(arg)) {
-                    uint len;
+                    mp_uint_t len;
                     const char *s = mp_obj_str_get_data(arg, &len);
                     if (len != 1) {
                         nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "%%c requires int or char"));
@@ -1735,7 +1734,7 @@ const mp_obj_type_t mp_type_bytes = {
 STATIC const mp_obj_str_t empty_bytes_obj = {{&mp_type_bytes}, 0, 0, NULL};
 const mp_obj_t mp_const_empty_bytes = (mp_obj_t)&empty_bytes_obj;
 
-mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, uint len, byte **data) {
+mp_obj_t mp_obj_str_builder_start(const mp_obj_type_t *type, mp_uint_t len, byte **data) {
     mp_obj_str_t *o = m_new_obj(mp_obj_str_t);
     o->base.type = type;
     o->len = len;
@@ -1778,7 +1777,7 @@ mp_obj_t mp_obj_new_str_of_type(const mp_obj_type_t *type, const byte* data, uin
     return o;
 }
 
-mp_obj_t mp_obj_new_str(const char* data, uint len, bool make_qstr_if_not_already) {
+mp_obj_t mp_obj_new_str(const char* data, mp_uint_t len, bool make_qstr_if_not_already) {
     if (make_qstr_if_not_already) {
         // use existing, or make a new qstr
         return MP_OBJ_NEW_QSTR(qstr_from_strn(data, len));
@@ -1799,7 +1798,7 @@ mp_obj_t mp_obj_str_intern(mp_obj_t str) {
     return MP_OBJ_NEW_QSTR(qstr_from_strn((const char*)data, len));
 }
 
-mp_obj_t mp_obj_new_bytes(const byte* data, uint len) {
+mp_obj_t mp_obj_new_bytes(const byte* data, mp_uint_t len) {
     return mp_obj_new_str_of_type(&mp_type_bytes, data, len);
 }
 
@@ -1830,7 +1829,7 @@ STATIC void arg_type_mixup() {
     nlr_raise(mp_obj_new_exception_msg(&mp_type_TypeError, "Can't mix str and bytes arguments"));
 }
 
-uint mp_obj_str_get_hash(mp_obj_t self_in) {
+mp_uint_t mp_obj_str_get_hash(mp_obj_t self_in) {
     // TODO: This has too big overhead for hash accessor
     if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) {
         GET_STR_HASH(self_in, h);
@@ -1840,7 +1839,7 @@ uint mp_obj_str_get_hash(mp_obj_t self_in) {
     }
 }
 
-uint mp_obj_str_get_len(mp_obj_t self_in) {
+mp_uint_t mp_obj_str_get_len(mp_obj_t self_in) {
     // TODO This has a double check for the type, one in obj.c and one here
     if (MP_OBJ_IS_STR(self_in) || MP_OBJ_IS_TYPE(self_in, &mp_type_bytes)) {
         GET_STR_LEN(self_in, l);
@@ -1875,7 +1874,7 @@ const char *mp_obj_str_get_str(mp_obj_t self_in) {
     }
 }
 
-const char *mp_obj_str_get_data(mp_obj_t self_in, uint *len) {
+const char *mp_obj_str_get_data(mp_obj_t self_in, mp_uint_t *len) {
     if (MP_OBJ_IS_STR_OR_BYTES(self_in)) {
         GET_STR_DATA_LEN(self_in, s, l);
         *len = l;
diff --git a/py/runtime.c b/py/runtime.c
index 69727e0203121ce714c89f6208e03d03a9f97783..41bd198040acdc40fb92252fce47dda9774be64a 100644
--- a/py/runtime.c
+++ b/py/runtime.c
@@ -1094,7 +1094,7 @@ import_error:
     }
 
     mp_load_method_maybe(module, MP_QSTR___name__, dest);
-    uint pkg_name_len;
+    mp_uint_t pkg_name_len;
     const char *pkg_name = mp_obj_str_get_data(dest[0], &pkg_name_len);
 
     const uint dot_name_len = pkg_name_len + 1 + qstr_len(name);
diff --git a/py/sequence.c b/py/sequence.c
index e180bf1d69dbdcf22c7f956560780dc7c86f6628..ad6033110d114e373fdade02b60c24f8b571139f 100644
--- a/py/sequence.c
+++ b/py/sequence.c
@@ -43,7 +43,7 @@
 
 // Implements backend of sequence * integer operation. Assumes elements are
 // memory-adjacent in sequence.
-void mp_seq_multiply(const void *items, uint item_sz, uint len, uint times, void *dest) {
+void mp_seq_multiply(const void *items, mp_uint_t item_sz, mp_uint_t len, mp_uint_t times, void *dest) {
     for (int i = 0; i < times; i++) {
         uint copy_sz = item_sz * len;
         memcpy(dest, items, copy_sz);
@@ -102,7 +102,7 @@ bool mp_seq_get_fast_slice_indexes(mp_uint_t len, mp_obj_t slice, mp_bound_slice
 
 #endif
 
-mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *indexes) {
+mp_obj_t mp_seq_extract_slice(mp_uint_t len, const mp_obj_t *seq, mp_bound_slice_t *indexes) {
     mp_int_t start = indexes->start, stop = indexes->stop;
     mp_int_t step = indexes->step;
 
@@ -125,7 +125,7 @@ mp_obj_t mp_seq_extract_slice(uint len, const mp_obj_t *seq, mp_bound_slice_t *i
 
 // Special-case comparison function for sequences of bytes
 // Don't pass MP_BINARY_OP_NOT_EQUAL here
-bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, uint len2) {
+bool mp_seq_cmp_bytes(int op, const byte *data1, mp_uint_t len1, const byte *data2, mp_uint_t len2) {
     if (op == MP_BINARY_OP_EQUAL && len1 != len2) {
         return false;
     }
@@ -169,7 +169,7 @@ bool mp_seq_cmp_bytes(int op, const byte *data1, uint len1, const byte *data2, u
 
 // Special-case comparison function for sequences of mp_obj_t
 // Don't pass MP_BINARY_OP_NOT_EQUAL here
-bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *items2, uint len2) {
+bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, mp_uint_t len1, const mp_obj_t *items2, mp_uint_t len2) {
     if (op == MP_BINARY_OP_EQUAL && len1 != len2) {
         return false;
     }
@@ -218,7 +218,7 @@ bool mp_seq_cmp_objs(int op, const mp_obj_t *items1, uint len1, const mp_obj_t *
 }
 
 // Special-case of index() which searches for mp_obj_t
-mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp_obj_t *args) {
+mp_obj_t mp_seq_index_obj(const mp_obj_t *items, mp_uint_t len, mp_uint_t n_args, const mp_obj_t *args) {
     mp_obj_type_t *type = mp_obj_get_type(args[0]);
     mp_obj_t *value = args[1];
     uint start = 0;
@@ -241,7 +241,7 @@ mp_obj_t mp_seq_index_obj(const mp_obj_t *items, uint len, uint n_args, const mp
     nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "object not in sequence"));
 }
 
-mp_obj_t mp_seq_count_obj(const mp_obj_t *items, uint len, mp_obj_t value) {
+mp_obj_t mp_seq_count_obj(const mp_obj_t *items, mp_uint_t len, mp_obj_t value) {
     mp_uint_t count = 0;
     for (uint i = 0; i < len; i++) {
          if (mp_obj_equal(items[i], value)) {
diff --git a/unix/modffi.c b/unix/modffi.c
index b5ab35e7c47b2ba85d3175d4121e6a514d5483a5..c788f5dd268e76934b485e476ff8b53e731f18c0 100644
--- a/unix/modffi.c
+++ b/unix/modffi.c
@@ -124,7 +124,7 @@ STATIC ffi_type *char2ffi_type(char c)
 STATIC ffi_type *get_ffi_type(mp_obj_t o_in)
 {
     if (MP_OBJ_IS_STR(o_in)) {
-        uint len;
+        mp_uint_t len;
         const char *s = mp_obj_str_get_data(o_in, &len);
         ffi_type *t = char2ffi_type(*s);
         if (t != NULL) {
diff --git a/unix/modos.c b/unix/modos.c
index 5cd78a99fbd699052df695e9e4b9181e70f55991..90998bcffe426851c5e20ccf9535d168f3897d86 100644
--- a/unix/modos.c
+++ b/unix/modos.c
@@ -44,7 +44,7 @@
 
 STATIC mp_obj_t mod_os_stat(mp_obj_t path_in) {
     struct stat sb;
-    uint len;
+    mp_uint_t len;
     const char *path = mp_obj_str_get_data(path_in, &len);
 
     int res = stat(path, &sb);
diff --git a/unix/modtermios.c b/unix/modtermios.c
index 56e1c5e83a58aa70f3f4e88cd52f7126546b7f07..f9884da90332e70fd7ec9997b2d08fe9f27f0fe0 100644
--- a/unix/modtermios.c
+++ b/unix/modtermios.c
@@ -88,7 +88,7 @@ STATIC mp_obj_t mod_termios_tcsetattr(mp_obj_t fd_in, mp_obj_t when_in, mp_obj_t
         if (i == VMIN || i == VTIME) {
             term.c_cc[i] = mp_obj_get_int(cc->items[i]);
         } else {
-            uint len;
+            mp_uint_t len;
             term.c_cc[i] = *mp_obj_str_get_data(cc->items[i], &len);
         }
     }