Refactor connection
Log fatal errors for database connections