Added image_refs code, and ability to remove image from gallery