Cherry-pick https://github.com/eucalyptus/koala/commit/23539dad758254a08f3f051fd61d6174b90b0b60