Refactor the plugin manager to be more readable, focused

Refactoring related to issue #3519