Added reset and cleaned up error handling