bunch of messy server stuff