Massive refactoring of 2.0-dev codebase.