Consolidated code

Not done yet, but let's touch base.