Definitive version of the fully optimized algorithm with the useless last improvement
Also, new script to produce multiple debug outputs at once