Lots of cleanup, also got plugins working