Fixed memory leak while starting up/closing plugin multiple times