Fixed bugs with offline handling in cordova