Improvements on gen-termfreq.py