Some cleanup. Simplify event dispatcher a bit.