Refactor database to use a single list of callbacks