use collections.defaultdict, not LBYL
remove unused code