Converted https://github.com/timvideos/planet/commit/4801511c2e31878595f945b2a1e1354197f1cff6