Fixed some bugs with start scripts and improved server stop scripts

Fixed some bugs related with server start and server stop.