event now uses defaultdict

Some code cleanup. The unittests are updated and refined (now looks
99.87% better).