Rework image model handling
Simplifies the code and fixes the wrong image being opened bcause of index confusion