fixed cleanup of injected script, improved auto-update behavior