Converted https://github.com/timvideos/planet/commit/cd5c639d9ce6a707a9bb785b0c20de645919ae42