taking care of PEP8/code cleanup
defaultdict usage, cleanup for readability