Refactors to be Cordova 3.x compatible