another pass at cleanup and bug finding, mostly focused on the master server