Split up the huge main function into several smaller functions that
handle specific server messages