Organization

Code organization and refactoring