Hunspell: optimize loops and fix formatting