Improve generate's reliability, fixes #202

This also improves speed on multi language books
Merge pull request #203 from GitbookIO/improve/generate

Improve generate's reliability, fixes #202