more updates and refactoring.