Implemented production priority dynamic choosing. Refined error recovery algorithm.