Fix some bugs in generation