Some performance improvements

I replaced some sprintf()s with memcpy()-constructs here and there.
Looks ugly but is fast.