Refactored the big getcombinedImage function and split it in two.