Complete revision of image annotation code