Refactoring to enable running the algorithm in autonomous or stepwise
(debug) modes.