Cleaning up plugins, getting rid of globals