Converted https://github.com/timvideos/planet/commit/0c8410c1522d22b52af771c0b7783ed8fc025807