This new cleanup code fixes the race condition.  Note that any pending onload handler is cleared by _clearImage().