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