Yet more refactorings and cleanup for 2.0