Make plugins a package, fixes import error
Various stylistic fixes and minor bug fixes
Stop leaking file handles