Even more massive code inspection/refactoring.