Refactor to plugin.