Initial work.
Merged in almost completely broken event chain from a local branch.