Now uses collections.defaultdict; Cleaned up docstrings; Moved data into ifmain block