Updated with better global handles, api to retrieve current image.