Move client connection handling to a separate file