Refactor out Server to main