Minor modifications: NSParameterAssert statements were added, "weakSelf" removed, if statement blocks corrected.