     }
     
     override func touchesEnded(touches: Set<UITouch>, withEvent event: UIEvent?) {
-        for object in touches {
-            if let touch = object as? UITouch {
-                let touchID = FTPenManager.sharedInstance().classifier.idForTouch(touch)
-                if let touchInfo = self.touches[touchID] {
-                    let point = touch.locationInView(self.scrollView)
+        for touch in touches {
+            let touchID = FTPenManager.sharedInstance().classifier.idForTouch(touch)
+            if let touchInfo = self.touches[touchID] {
+                let point = touch.locationInView(self.scrollView)
+                
+                touchInfo.currentStroke.addPoint(point)
+                touchInfo.phase = .Ended
+                
+                // See if this was a tap
+                var wasTap = false
+                if touch.timestamp - touchInfo.initialTime < dragDelayTime && touchInfo.initialPoint.distanceTo(point) <= dragMaxDistance {
+                    wasTap = true
+                    for point in touchInfo.currentStroke.points {
+                        // Only if all points were within the threshold was it a tap
+                        if touchInfo.initialPoint.distanceTo(point) > dragMaxDistance {
+                            wasTap = false
+                            break
+                        }
+                    }
+                }
+                if wasTap {
+                    if touchInfo.classification != nil {
+                        undoEffectsOfGestureInProgress(touchInfo)
+                    }
                     
-                    touchInfo.currentStroke.addPoint(point)
-                    touchInfo.phase = .Ended
-                    
-                    // See if this was a tap
-                    var wasTap = false
-                    if touch.timestamp - touchInfo.initialTime < dragDelayTime && touchInfo.initialPoint.distanceTo(point) <= dragMaxDistance {
-                        wasTap = true
-                        for point in touchInfo.currentStroke.points {
-                            // Only if all points were within the threshold was it a tap
-                            if touchInfo.initialPoint.distanceTo(point) > dragMaxDistance {
-                                wasTap = false
-                                break
-                            }
-                        }
-                    }
-                    if wasTap {
-                        if touchInfo.classification != nil {
-                            undoEffectsOfGestureInProgress(touchInfo)
-                        }
-                        
-                        let isDeleteTap = usePenClassifications() ? touchInfo.classification == .Delete :  touch.tapCount == 2
-                        if !isDeleteTap {
-                            // This is a selection tap
-                            if let (connectorLabel, offset) = touchInfo.connectorLabel {
-
-                                if usePenClassifications() {
-                                    if self.selectedConnectorLabel != connectorLabel {
-                                        self.selectedConnectorLabel = connectorLabel
-                                    } else {
-                                        self.selectedConnectorLabel = nil
-                                    }
+                    let isDeleteTap = usePenClassifications() ? touchInfo.classification == .Delete :  touch.tapCount == 2
+                    if !isDeleteTap {
+                        // This is a selection tap
+                        if let (connectorLabel, _) = touchInfo.connectorLabel {
+                            
+                            if usePenClassifications() {
+                                if self.selectedConnectorLabel != connectorLabel {
+                                    self.selectedConnectorLabel = connectorLabel
                                 } else {
-                                    // We delay this by a bit, so that the selection doesn't happen if a double-tap completes and the connector is deleted
-                                    delay(dragDelayTime) {
-                                        if let _ = self.connectorLabels.indexOf(connectorLabel) { // It will be found unless it has been deleted
-                                            if self.selectedConnectorLabel != connectorLabel {
-                                                self.selectedConnectorLabel = connectorLabel
-                                            } else {
-                                                self.selectedConnectorLabel = nil
-                                            }
+                                    self.selectedConnectorLabel = nil
+                                }
+                            } else {
+                                // We delay this by a bit, so that the selection doesn't happen if a double-tap completes and the connector is deleted
+                                delay(dragDelayTime) {
+                                    if let _ = self.connectorLabels.indexOf(connectorLabel) { // It will be found unless it has been deleted
+                                        if self.selectedConnectorLabel != connectorLabel {
+                                            self.selectedConnectorLabel = connectorLabel
+                                        } else {
+                                            self.selectedConnectorLabel = nil
                                         }
                                     }
                                 }
-                                
-                            } else if let connectorPort = touchInfo.constraintView?.ConnectorPort {
-                                if self.selectedConnectorPort?.ConnectorPort !== connectorPort {
-                                    let constraintView = touchInfo.constraintView!.ConstraintView
-                                    self.selectedConnectorPort = (constraintView, connectorPort)
-                                } else {
-                                    self.selectedConnectorPort = nil
-                                }
-                                
-                            } else if let (connectorLabel, constraintView, connectorPort) = self.connectionLineAtPoint(point) {
-                                let lastValue = self.lastValueForConnector(connectorLabel.connector)
-                                let lastValueWasDependent = self.lastValueWasDependentForConnector(connectorLabel.connector)
-                                
-                                if (lastValueWasDependent != nil && lastValueWasDependent!) {
-                                    // Try to make this connector high priority, so it is constant instead of dependent
-                                    moveConnectorToTopPriority(connectorLabel)
-                                } else {
-                                    // Lower the priority of this connector, so it will be dependent
-                                    moveConnectorToBottomPriority(connectorLabel)
-                                }
-                                updateDisplay(needsSolving: true)
-                                
+                            }
+                            
+                        } else if let connectorPort = touchInfo.constraintView?.ConnectorPort {
+                            if self.selectedConnectorPort?.ConnectorPort !== connectorPort {
+                                let constraintView = touchInfo.constraintView!.ConstraintView
+                                self.selectedConnectorPort = (constraintView, connectorPort)
                             } else {
-                                // De-select everything
-                                // TODO: What if they were just drawing a point?
-                                self.selectedConnectorLabel = nil
                                 self.selectedConnectorPort = nil
                             }
                             
+                        } else if let (connectorLabel, _, _) = self.connectionLineAtPoint(point) {
+                            let lastValueWasDependent = self.lastValueWasDependentForConnector(connectorLabel.connector)
+                            
+                            if (lastValueWasDependent != nil && lastValueWasDependent!) {
+                                // Try to make this connector high priority, so it is constant instead of dependent
+                                moveConnectorToTopPriority(connectorLabel)
+                            } else {
+                                // Lower the priority of this connector, so it will be dependent
+                                moveConnectorToBottomPriority(connectorLabel)
+                            }
+                            updateDisplay(needsSolving: true)
+                            
                         } else {
-                            // This is a delete tap
-                            var deletedSomething = false
-                            if let (connectorLabel, offset) = touchInfo.connectorLabel {
-                                // Delete this connector!
-                                removeConnectorLabel(connectorLabel)
+                            // De-select everything
+                            // TODO: What if they were just drawing a point?
+                            self.selectedConnectorLabel = nil
+                            self.selectedConnectorPort = nil
+                        }
+                        
+                    } else {
+                        // This is a delete tap
+                        var deletedSomething = false
+                        if let (connectorLabel, _) = touchInfo.connectorLabel {
+                            // Delete this connector!
+                            removeConnectorLabel(connectorLabel)
+                            deletedSomething = true
+                        }
+                        if deletedSomething == false {
+                            if let (constraintView, _, _) = touchInfo.constraintView {
+                                // Delete this constraint!
+                                removeConstraintView(constraintView)
                                 deletedSomething = true
                             }
-                            if deletedSomething == false {
-                                if let (constraintView, offset, connectorPort) = touchInfo.constraintView {
-                                    // Delete this constraint!
-                                    removeConstraintView(constraintView)
-                                    deletedSomething = true
-                                }
-                            }
-                            
-                            if deletedSomething {
-                                updateDisplay(needsSolving: true, needsLayout: true)
-                            }
-                        }
-                        
-                    } else if touchInfo.classification != nil {
-                        completeGestureForTouch(touchInfo)
+                        }
+                        
+                        if deletedSomething {
+                            updateDisplay(needsSolving: true, needsLayout: true)
+                        }
                     }
                     
-                    self.touches[touchID] = nil
-                }
+                } else if touchInfo.classification != nil {
+                    completeGestureForTouch(touchInfo)
+                }
+                
+                self.touches[touchID] = nil
             }
         }
     }

    let dragMaxDistance: CGFloat = 10
    
    override func touchesBegan(touches: Set<UITouch>, withEvent event: UIEvent?) {
        for object in touches {
            if let touch = object as? UITouch {
                let point = touch.locationInView(self.scrollView)
                
                var touchInfo = TouchInfo(initialPoint: point, initialTime: touch.timestamp)
                
                if let connectorLabel = self.connectorLabelAtPoint(point) {
                    touchInfo.connectorLabel = (connectorLabel, connectorLabel.center - point)
                    
                } else if let (constraintView, connectorPort) = self.connectorPortAtLocation(point) {
                    touchInfo.constraintView = (constraintView, constraintView.center - point, connectorPort)
                    
                } else if let constraintView = self.constraintViewAtPoint(point) {
                    touchInfo.constraintView = (constraintView, constraintView.center - point, nil)
                    
                }
                
                let touchID = FTPenManager.sharedInstance().classifier.idForTouch(touch)
                self.touches[touchID] = touchInfo
                
                if (!usePenClassifications()) {
                    // Test for a long press, to trigger a drag
                    if (touchInfo.connectorLabel != nil || touchInfo.constraintView != nil) {
                        delay(dragDelayTime) {
                            // If this still hasn't been classified as something else (like a connection draw), then it is a move
                            if touchInfo.classification == nil {
                                if touchInfo.phase == .Began || touchInfo.phase == .Moved {
                                    self.changeTouchToClassification(touchInfo, classification: .Drag)
                                }
                            }
                        }
                    }
                }
                
                let classification = penClassificationForTouch(touch)
                if classification == nil || classification! != .Palm {
                    if let lastStroke = self.unprocessedStrokes.last, lastStrokeLastPoint = lastStroke.points.last {
                        if euclidianDistance(lastStrokeLastPoint, b: point) > 150 {
                            // This was far away from the last stroke, so we process that stroke
                            processStrokes()
                        }
                    }
                }
            }

                completeDrawConnectionGesture(touchInfo)
                
            case .Drag:
                if let (pickedUpView, _) = touchInfo.pickedUpView() {
                    updateDragGesture(touchInfo)
                    setViewPickedUp(pickedUpView, pickedUp: false)
                    updateScrollableSize()
