Refactor core into a Server type