diff --git a/py/binary.c b/py/binary.c
index 3f1d7f286729f3a8ceaabf9e46f1fca764546126..65688272aab4b9548fe304c5d00260742efe769a 100644
--- a/py/binary.c
+++ b/py/binary.c
@@ -26,6 +26,7 @@
 
 #include <stdint.h>
 #include <stdlib.h>
+#include <stddef.h>
 #include <string.h>
 #include <assert.h>
 
@@ -37,6 +38,10 @@
 
 // Helpers to work with binary-encoded data
 
+#ifndef alignof
+#define alignof(type) offsetof(struct { char c; type t; }, t)
+#endif
+
 int mp_binary_get_size(char struct_type, char val_type, uint *palign) {
     int size = 0;
     int align = 1;
@@ -68,16 +73,20 @@ int mp_binary_get_size(char struct_type, char val_type, uint *palign) {
                 case 'b': case 'B':
                     align = size = 1; break;
                 case 'h': case 'H':
-                    align = size = sizeof(short); break;
+                    align = alignof(short);
+                    size = sizeof(short); break;
                 case 'i': case 'I':
-                    align = size = sizeof(int); break;
+                    align = alignof(int);
+                    size = sizeof(int); break;
                 case 'l': case 'L':
-                    align = size = sizeof(long); break;
+                    align = alignof(long);
+                    size = sizeof(long); break;
                 case 'q': case 'Q':
-                    // TODO: This is for x86
-                    align = sizeof(int); size = sizeof(long long); break;
+                    align = alignof(long long);
+                    size = sizeof(long long); break;
                 case 'P': case 'O': case 'S':
-                    align = size = sizeof(void*); break;
+                    align = alignof(void*);
+                    size = sizeof(void*); break;
             }
         }
     }
diff --git a/py/objstr.c b/py/objstr.c
index 6ec997f4bf26952a4ad431f15bcfd0128602653a..9d346098822dd61299ba6423355aa3f6208e7b3d 100644
--- a/py/objstr.c
+++ b/py/objstr.c
@@ -472,6 +472,9 @@ STATIC mp_obj_t str_split(uint n_args, const mp_obj_t *args) {
 
     } else {
         // sep given
+        if (mp_obj_get_type(sep) != self_type) {
+            arg_type_mixup();
+        }
 
         uint sep_len;
         const char *sep_str = mp_obj_str_get_data(sep, &sep_len);
diff --git a/unix/modsocket.c b/unix/modsocket.c
index d5b8e11c243f80713278a4122805fb627169fb60..7eae1d8bf9f2daebe79e18fd5f9f7af067ca1a9f 100644
--- a/unix/modsocket.c
+++ b/unix/modsocket.c
@@ -45,6 +45,7 @@
 #include "obj.h"
 #include "objtuple.h"
 #include "objarray.h"
+#include "objstr.h"
 #include "runtime.h"
 #include "stream.h"
 #include "builtin.h"
@@ -179,11 +180,11 @@ STATIC mp_obj_t socket_recv(uint n_args, const mp_obj_t *args) {
         flags = MP_OBJ_SMALL_INT_VALUE(args[2]);
     }
 
-    char *buf = m_new(char, sz);
+    byte *buf = m_new(byte, sz);
     int out_sz = recv(self->fd, buf, sz, flags);
     RAISE_ERRNO(out_sz, errno);
 
-    mp_obj_t ret = MP_OBJ_NEW_QSTR(qstr_from_strn(buf, out_sz));
+    mp_obj_t ret = mp_obj_new_str_of_type(&mp_type_bytes, buf, out_sz);
     m_del(char, buf, sz);
     return ret;
 }