fixed possible memory leak when enabling/disabling the extension