     }
     
     var cstr = [CChar](count: data.count + 1, repeatedValue: 0)
-    cstr.withUnsafePointerToElements { dest in  // cannot just use cstr!
-      data.withUnsafePointerToElements { src in
-        memcpy(dest, src, UInt(data.count))
-      }
-    }
+    memcpy(&cstr, data, UInt(data.count))
     cstr[data.count] = 0 // 0-terminate
     
-    // var s = "" // direct return seems to crash things, not sure why
-    return cstr.withUnsafePointerToElements {
-      return String.fromCString($0)!
-    }
+    return String.fromCString(cstr)!
   }
   
   func dataInCStringEncoding() -> [UInt8] {
-    return self.withCString { (cstr: ConstUnsafePointer<CChar>) in
+    return self.withCString { (cstr: UnsafePointer<CChar>) in
       let len  = strlen(cstr)
       if len < 1 {
         return [UInt8]()
       }
       var buf = [UInt8](count: Int(len), repeatedValue: 0)
-      buf.withUnsafePointerToElements { dest in
-        memcpy(dest, cstr, len)
-      }
+      memcpy(&buf, cstr, len)
       return buf
     }
   }

public extension String {
  
  static func fromCString
    (cs: ConstUnsafePointer<CChar>, length: Int!) -> String?
  {
    if length == .None { // no length given, use \0 standard variant
      return String.fromCString(cs)
    }
    
    let buflen = length + 1
    var buf    = UnsafePointer<CChar>.alloc(buflen)
    memcpy(buf, cs, UInt(length))
    buf[length] = 0 // zero terminate
    let s = String.fromCString(buf)

import Darwin

// This allows you to do: str[str.startIndex..idx+4]
public func +<T: ForwardIndexType>(idx: T, distance: T.DistanceType) -> T {
  return advance(idx, distance)
}
public func +<T: ForwardIndexType>(distance: T.DistanceType, idx: T) -> T {
  return advance(idx, distance)
}

public func -<T:BidirectionalIndexType where T.DistanceType : SignedIntegerType>
  (idx: T, distance: T.DistanceType) -> T
{
  var cursor = idx
