Refactoring of plugins loading code