More refactoring, simplification of doc event code.