More optimizations for algorithms, 90 per cent complete.