Fixed some bugs which caused generator to incorrectly process lists sometimes