Group vectors to exploit cache effects. 

Code is a bit uglier and has repetitions for now. But I will clean up that later hopefully. Performance seems to be better.