cherry-pick merge from https://github.com/ejorreto/WiFly/commit/71e5b00c1a11aead4ea3ba252cc31663be3c46be