This function looks like it's doing too much and doing it at the wrong time. It should be possible to read the images on demand, from a delegated listener, instead of reading them all in at the end of every render. Doing it this way we're going to eat a ton of memory that we don't need, which is bad considering that Caret is often used on very low-memory devices.