Fix some bugs in conditions and iterator