Fix string.c to handle NULL strings, and some other bugfixes