This should improve readability in gimp.c, and moves all data factory handling code to a common place.