added proper server startup and error handling