Use structure of arrays instead of array of structures.

This improves performance and simplifies code in some places.