factor out Server implementation separate from Thread