Fix encoding of CF.hs and some code improvement