Refactor some of the plugin wrapper code to be slicker (and possibly slightly
faster).