Let's eliminate these three allocations.  You can do something similar to what the original code did.  Let me know if you're not sure what I mean.