Some error handling bug fixes and Shutdown support