Avoid crash when just trying to fit images when they are actually not yet loaded
Corrected bug that could make infinite loop