improve handling of server starting/stopping

also general cleanup