Thanks for all of the help.
I can't remove the addon as it is forced on at work.
Im not sure why I was setting the bool at the start of the layout. I have removed this and changed the initial value.
I have now changed to deactivating the group at the start, which works much better and means I don't need to add waits into my code.
Thanks again :)