Converted https://github.com/timvideos/planet/commit/678b41ce24d07e8fb5187626970a8138163ac27a