Don't create images/framebuffers that won't be used, and add checks before use.