Event Handlers added at reload

I have a few event handlers in a startup.py script, whenever a user reloads pyrevit (not super often but it does happen) it creates a duplicate of those event handlers. This is causing errors in the code because it’s trying to perform the action twice.
Is there a way to remove/overwrite existing event handlers in a startup.py script?

Would converting these to hook scripts solve my issue?

From my tiny experience, i couldn’t manage with adding or removing eventHandlers, so the workaround is just to check, if event handler has been already registered by PyRevit during current session.

So the algorythm is as following (this is a pseudocode)

    event_handler_already_registered = script.get_envvar("MY_VAR")
except: event_handler_already_registered = False

if not event_handler_already_registered or event_handler_already_registered==None:
        __rvt__.Application.DocumentOpened += your_event_handler
        script.set_envvar("MY_VAR", True)
    except Exception as ex:
        script.get_logger().dev_log("ERROR:", str(ex))

The value of MY_VAR is not reseted between PyRevit reloads, so pyRevit will “remember” the environment variable between its reloads