Major refactor in preparation to adding physical plans. Removed
unnecessary intermediate calculus.