Added additional logging for errors.