Merge refactor to master branch.

Clean up complete so merge this stuff.