Fixed a lot of things in split_sstring() and refactored it a bit.

Mainly fixed it ignoring separators at the end of string instead of removing them, appending a NULL string sometimes, not removing a separator at the start, etc.
Refactored split_sstring() to make it more readable and added check for when stuff doesn't get copied over properly.