Lockstep bug fix, refactoring.