solving infinite loop and fixing some other bugs for flickr