Server: simplify code, more comments