Continued refactoring. Still in progress