Frequency structure output to file

Tiered HashMap structure output to text file.

Minor refactoring.