Small facelift

Created some utils of general interest and slightly unwound the most complex function in `Server`. That small part of the world should be quite a bit easier to refactor now.