There's a memory leak here I think (which has been there for an age)... If you make this:
```
MCAutoPointer<char> startptr = new char[slength + 1];
```
You can remove the 'delete startptr' lines, and the string will still be freed (previously there were a couple of places where the function returns without deleting it, the auto class means it will be done for you).