Removing some hard coding and abstracting it with callbacks, so that it works with more than one plugin.