RESTYLIZED! server. Attempting to clean up code so there's less levels of indentation, perhaps by breaking it into functions.