Clean up and refactoring round 3