Refactoring, many enhancements