Improved the algorithm by reducing the amount of base prims, therefore they fit into L1 cache and improve speed a bit.