Improve generate's reliability, fixes #202

This also improves speed on multi language books