Engine Overhaul

Completely replaced the engine with something that is more unit
testable.