C++ server code

Latest master merged in. We should discuss the layout of the code.
indenting is one level too deep in this function, adding to list