                     nextPoint.x - CGFloat(xDir * cornerRadius),
                     nextPoint.y + CGFloat(shadowOffset) - CGFloat(yDir * cornerRadius))
                 
-                segmentPoints += (p0, p1)
+                self._segmentPoints += (p0, p1)
                 
                 let c = CGPointMake(
                     p0.x - CGFloat(yDir * cornerRadius),
                     p0.y + CGFloat(xDir * cornerRadius))
                 
-                arcCenters += c
-            }
-            
-            // here be where we do the drawing
-            
-            if self._attached && self._attached!.toRaw() == 0 {
-                CGPathMoveToPoint(path, nil, segmentPoints[1].0.x, segmentPoints[1].0.y)
-            }
-            else {
-                CGPathMoveToPoint(path, nil, segmentPoints[0].0.x, segmentPoints[0].0.y)
-            }
-            
-            for i in 0..<4 {
-                if self._attached && self._attached!.toRaw() == i {
-                    continue
-                }
-                
-                CGPathAddLineToPoint(path, nil, segmentPoints[i].0.x, segmentPoints[i].0.y)
-                CGPathAddLineToPoint(path, nil, segmentPoints[i].1.x, segmentPoints[i].1.y)
-                
-                if (self._attached && (self._attached!.toRaw() + 4 - 1) % 4 == i) {
-                    // do nothing
-                } else {
-                    CGPathAddRelativeArc(path, nil, arcCenters[(i + 1) % 4].x, arcCenters[(i + 1) % 4].y, CGFloat(cornerRadius), arcStartingAngles[(i + 1) % 4], CGFloat(M_PI/2.0))
-                }
-            }
-            
-            CGPathCloseSubpath(path)
-            
-            let mainColor = (self.highlighted ? self.downColor : self.color).CGColor
-            let shadowColor = (self.highlighted ? self.downShadowColor : self.shadowColor).CGColor
-            
-            CGContextSetFillColorWithColor(ctx, shadowColor)
-            CGContextAddPath(ctx, path)
-            CGContextFillPath(ctx)
-            
-            CGContextSetFillColorWithColor(ctx, mainColor)
-            CGContextTranslateCTM(ctx, 0, -CGFloat(shadowOffset))
-            CGContextAddPath(ctx, path)
-            CGContextFillPath(ctx)
-            CGContextTranslateCTM(ctx, 0, CGFloat(shadowOffset))
-            
-            /////////////
-            // cleanup //
-            /////////////
-            
-            CGColorSpaceRelease(csp)
-            CGPathRelease(path)
+                self._arcCenters += c
+            }
         }
         
         func attachmentPoints(direction: Direction) -> (CGPoint, CGPoint) {
-            return (CGPointZero, CGPointZero)
+            return self._segmentPoints[direction.toRaw()]
         }
         
         func attach(direction: Direction?) {

            ]
            
            // actual coordinates for each edge, including translation
            var segmentPoints: [(CGPoint, CGPoint)] = [] // TODO: is this declaration correct?
            
            // actual coordinates for arc centers for each corner
            var arcCenters: [CGPoint] = []
            
            var arcStartingAngles: [CGFloat] = []
            
            for i in 0..<startingPoints.count {
                let currentPoint = startingPoints[i]
                let nextPoint = startingPoints[(i + 1) % startingPoints.count]
                
                var xDir = 0.0
                var yDir = 0.0
                
                if (i == 1) {
                    xDir = 1.0
                    arcStartingAngles += CGFloat(M_PI)
                }
                else if (i == 3) {
                    xDir = -1.0
                    arcStartingAngles += CGFloat(0)
                }
                
                if (i == 0) {
                    yDir = -1.0
                    arcStartingAngles += CGFloat(M_PI/2.0)
                }
                else if (i == 2) {
                    yDir = 1.0
                    arcStartingAngles += CGFloat(-M_PI/2.0)
                }
                
                let p0 = CGPointMake(


enum Direction: Int {
    case Left = 0
    case Down = 3
    case Right = 2
    case Up = 1
    
    mutating func inverse() {
        switch self {
        case Left:
            self = Right
        case Right:
            self = Left
        case Up:
            self = Down
        case Down:
            self = Up
        }
    }
}

protocol Connectable {
