I mostly added a few safties onto the string-lenght and substring
functions so they wouldn't cause a crash, but now somewhere there is
some error where string-append is trying to append to something that
isn't a string, but I have no idea where it is.