Original code from Niantic

Reverse engineered using Virtuous Ten Studio