factored server code and added a PlayerManager