Improvements to refactor for extensibility.