Sophia has pushed an update which removes the need to `size_t keysize = strlen(key) + 1`. We should now be able to remove all of that ugly logic now :)