Refactor database config loader