Support local images, cleanup code