Size calculation fix

Sometimes it would calculate the size of the element box incorrectly. Hard to re-create the issue but managed to get it constantly with one image on one site.

Apparently there are a lot of changes in this, but there is only one on line 116