Bug fix: getDatabase() is called recursively