Add missing database references.
Use correct database instance instead of null.