added code to close plugin loggers and a few other bug fixes