events = {};
 
     xhr.onreadystatechange = function () {
+        console.log(xhr.readyState);
         if (xhr.readyState == 4) {
             var status = xhr.status;
             var text = xhr.responseText;
             if (events.response != null)
                 events.response(status, text);
-            if (events.success != null)
-                if (status == 200)
+            if (status == 200) {
+                if (events.success != null)
                     events.success(text);
+            } else {
+                if (events.failure != null)
+                    events.failure(status);
+            }
         }
     };
 
 
     }
 }
 
+var rated = 0;
+
+var rating = function () {
+    var rating = package.rating;
+    if (rating == null)
+        $(".rating").remove();
+    else {
+        rating = 'fail.html';
+        $.xhr('_' + rating, 'GET', {}, null, {
+            success: function (value) {
+                document.getElementById("rating").contentWindow.document.write(value);
+            },
+
+            failure: function (status) {
+                $(".rating").remove();
+            }
+        });
+    }
+};
+
+var rating_ = function() {
+    if (rated == 0)
+        rated = 1;
+    else if (rated == 1) {
+        rating();
+        rated = -1;
+    }
+};
+
 $(function () {
     var id = package.id;
     var idc = encodeURIComponent(id);
     $("#name").html(name);
     space("#latest", package.latest, 93);
 
-    var rating = package.rating;
-    if (rating == null)
-        $(".rating").remove();
-    else {
-        $.xhr(rating, 'GET', {}, null, {
-            success: function (value) {
-                document.getElementById("rating").contentWindow.document.write(value);
-            }
-        });
-    }
+    rating_();
 
     $("#settings").href("cydia://package-settings/" + idc);
 
 
 
 #define lprintf(args...) fprintf(stderr, args)
 
-#define ForRelease 1
+#define ForRelease 0
 #define ForSaurik (1 && !ForRelease)
 #define IgnoreInstall (0 && !ForRelease)
 #define RecycleWebViews 0
 }*/
 
 int main(int argc, char *argv[]) { _pooled
+    _trace();
     class_addMethod(objc_getClass("DOMNodeList"), @selector(countByEnumeratingWithState:objects:count:), (IMP) &DOMNodeList$countByEnumeratingWithState$objects$count$, "I20@0:4^{NSFastEnumerationState}8^@12I16");
 
     bool substrate(false);
         Indices_ = [[NSMutableDictionary alloc] init];*/
 
     Indices_ = [NSMutableDictionary dictionaryWithObjectsAndKeys:
-        //@"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/server/rating/@", @"Rating",
+        @"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/rating/@", @"Rating",
         //@"http://"/*"cache.saurik.com/"*/"cydia.saurik.com/repotag/@", @"RepoTag",
     nil];
 
-    if ((Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"]) == NULL)
+    _trace();
+    Metadata_ = [[NSMutableDictionary alloc] initWithContentsOfFile:@"/var/lib/cydia/metadata.plist"];
+    _trace();
+
+    if (Metadata_ == NULL)
         Metadata_ = [[NSMutableDictionary alloc] initWithCapacity:2];
     else {
         Settings_ = [Metadata_ objectForKey:@"Settings"];
     /*if (substrate && access("/Library/MobileSubstrate/MobileSubstrate.dylib", F_OK) == 0)
         dlopen("/Library/MobileSubstrate/MobileSubstrate.dylib", RTLD_LAZY | RTLD_GLOBAL);*/
 
-    if (access("/User", F_OK) != 0)
+    if (access("/User", F_OK) != 0) {
+        _trace();
         system("/usr/libexec/cydia/firmware.sh");
+        _trace();
+    }
 
     _assert([[NSFileManager defaultManager]
         createDirectoryAtPath:@"/var/cache/apt/archives/partial"
     UIApplicationUseLegacyEvents(YES);
     UIKeyboardDisableAutomaticAppearance();
 
+    _trace();
     int value = UIApplicationMain(argc, argv, @"Cydia", @"Cydia");
 
     CGColorSpaceRelease(space_);
 
 Section: Packaging
 Maintainer: Jay Freeman (saurik) <saurik@saurik.com>
 Architecture: iphoneos-arm
-Version: 1.0.2677-38
+Version: 1.0.2678-38
 Replaces: com.sosiphone.addcydia
 Depends: apt, darwintools, pcre, shell-cmds
 Conflicts: com.sosiphone.addcydia