Fix infinite loop with loading images sometimes.