Prep to change to a plugin system; code cleanup