First unclean working version of the performance improvements