Miguel/plugin refactor

Relative to the main.js.