     Get Url to a file variant
     @return String.
     */
-    public func getVariantUrl (name: String) -> String {
+    public func getVariantUrl (name: String) -> String? {
 
         if(CONTENT_TYPES.FILE == self.subtype && hasVariant(name)){
-            return getUrl() + "?variant=" + name.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
+            if let url = getUrl() {
+                return url + "?variant=" + name.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
+            }
         }
         
-        return ""
+        return nil
     }
     
-    public func hasVariant(name: String) ->Bool{
-        var hasVariant = false
-        if (self.document["variants"] != nil) {
-            let varia = self.document["variants"] as! [AnyObject]
-            for variaitem in varia{
-                let variants = variaitem as! [String:AnyObject]
-                if(variants["name"] as! String == name){
-                    hasVariant = true
-                    break
+    public func hasVariant(name: String) -> Bool {
+        if let variants = self.document["variants"] as? [[String:AnyObject]] {
+            for variant in variants {
+                if(variant["name"] as! String == name){
+                    return true
                 }
             }
         }
-        return hasVariant;
+        return false;
     }
 
 }

    @return String.
    */

    public func getUrl () -> String {
        
        switch(self.subtype) {
        case .FILE:

            let escapeUrl = self.document["path"]!.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
            return hostUrl + "/api/delivery" + escapeUrl + "/index.html"
        case .URL:
            return self.document["url"] as? String
        default:
            return nil
        }
    }
    
