Merge refactoring

Tons of changes.