reverted engine change that broke cycling.
cleaning up engine a bit, splitting code with high cyclomatic complexity