Move some stuff around. Tidy up image generation