massive performance improvements to update loop