Refactoring

Did some simple refactoring and organization.