   // Expand template as a URI Template using the given variables
   public func expand(variables:[String:AnyObject]) -> String {
     let operatorHandlers:Dictionary<String, Expander> = [
-      "+": Expander(prefix: "", joiner: ",", { (key, string) -> String in
-        if let string = string {
-          return string.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
-        }
-
-        return ""
-      }),
-      "#": Expander(prefix: "#", joiner: ",", { (key, string) -> String in
-        if let string = string {
-          return string.stringByAddingPercentEscapesUsingEncoding(NSUTF8StringEncoding)!
-        }
-
-        return ""
-      }),
-      ".": Expander(prefix: ".", joiner: ".", { (key, string) -> String in
-        if let string = string {
-          return string
-        }
-
-        return ""
-      }),
+      "+": Expander(prefix: "", joiner: ",", expandPercentEscaped),
+      "#": Expander(prefix: "#", joiner: ",", expandPercentEscaped),
+      ".": Expander(prefix: ".", joiner: ".", expandValue),
       ";": Expander(prefix: ";", joiner: ";", { (key, string) -> String in
         if let string = string {
           if countElements(string) > 0 {

    return CFURLCreateStringByAddingPercentEscapes(nil, self, nil, ":/?&=;+!@#$()',*", CFStringConvertNSStringEncodingToEncoding(NSUTF8StringEncoding))
  }
}

public struct URITemplate : Printable, Equatable {
  let template:String


        return "\(key)"
      }),
      "&": Expander(prefix: "&", joiner: "&", expandKeyValue),
      "?": Expander(prefix: "?", joiner: "&", expandKeyValue),
      "/": Expander(prefix: "/", joiner: "/", expandValue),
    ]

    return regex.substitute(template) { string in
