Split server and client into 2 huge functions