refactored connection handling to pools and server context