Bug fixes, added clone to image code