Refactoring code to cocktail

Using a trait to resolve plugins. Some minor changes.