added stop server option, fixed error on first start

reformated code