Clean up GIF generation code with loops...