Allocate buffers contiguously in memory

Improves performance by 5-15%.