Improved performance by reducing the number of mysql queries.
Merge pull request #438 from koehn/master

Improved performance by reducing the number of mysql queries.