Refactoring to a better plugin architecture