Major refactoring of plugin to improve package cohesion.