Code cleanup and PEP8
Add Stats class to aggregate some statistics like from frequencies, etc.