Fix several issues around database and subscriptions.