Use result parameters everywhere possible.  Otherwise this code does quite a few allocations.