code cleaning, and a bug fix that called FB api in infinite loop