Merge keepAlive with non-keepAlive server code

Merge keepAlive with non-keepAlive server code