Converted https://github.com/timvideos/planet/commit/7037769693402445044f1e0a3a13315864eee4e8