Refactored services and db connection