Did some code rewriting. Python dicts ftw