Modified version of https://bitbucket.org/sullis/urbanairship-java/