Attach event listeners in db manager instead of app globals.

Makes it possible to create an engine without event listeners if desired,
occasionally useful in scripts.