Major overhaul of plugin