Fix some issues with connecting to databases.