Move plugin base functions into an include file
Improve comments
Unify style