Tighten up error handling