Add main document handler and onLaunched event support