Gum overlay logic

I did some rebasing and used git push force and I managed to loose the reference to the original pull request #229.

Anyway I've fixed the changes based on the comments in #229 and made a clean pull request.

Sorry for the hassle.

Fixes #137 .
I've tested reloading the page several times, when it's 0 3/10 times it will be sized incorrectly, I've also tried 100 and 200ms, it does also happen but less frequently. 300 seems to be a good compromise as I cannot repro at all using the same method as with the lower timeout values.