Moved everything I could into the one file to make it easier to port to other plugins.