> outBuf could be changed to a single string, and then you could remove the idup

Nice idea, now committed.