Refactor server proc a little