Eliminate image-loading race condition