Fixed a bug with the run history + factorized code handling images + code cleanup