Extract plugin management into its own class.

/cc @mattr-