step back and start with the fundamentals
what is sleep?
what does it do?
if its giving you implementation fits, ti may be an inherently ugly design choice.
instead of merely re-factoring, you might consider re-engineering.
"Everything becomes easy once you resort to customization."
Sometimes there is a different way.
I got not much idea how to rediesign it - but as i said I see vaguely that there is some problem with that.
Recently i began to think If I could maybe write small api to IncreaseSleep DecreaseSleep GetSleep SetSleep (?) in the window module - it will change some point from the reference spider side to code flow - accessin api call such
as IncreaseDleep is more narrow reference than accessing variable, so it may be more clear in conceptual.
I also think that this trouble with such Sleep integer is maybe related to that fact that Sleep has no physical value - the physical value has sleep() call not Sleep value which is only some kind of a temporary value and accessing with that value from different spots is more just an opportunity to spoil the code than anything else
We got a code containing & references plane and code flow plane in the code, i prefer to see things on code flow plane because there are much simpler (this is more seeable) but i am getting lost yet in some places of it