Fixed bugs in CFG generation