Alternative for #159, avoid some dynamic memory allocations

I don't have test data that uses this thing, so someone should make sure this works, but I think these allocations are neatly avoidable.