moved server related stuff out of main