Refactoring and moving DB connections to the server