Updated to treat NULL return values as errors from most types of return types