Fix performance issues when flipping between viewer and thumbnails