Refactor plugin code with fresh boilerplate

Plus some refactoring of parse functions