Refactoring to plugins