major changes and refactoring.