Clean up the code and add checks for warning failure mode handling.