Complete rewrite of the controller plugin