     func updateUI() {
         print("JAMVC: Updating UI.")
         
-        switch self.state {
+        switch state {
             
         case ChirpJamModes.new:
             
-            self.navigationItem.title = "New Performance"
+            navigationItem.title = "New Performance"
             if let replytext = self.replyto {
-                self.statusLabel.text = "reply to: " + replytext // setting reply to text
+                statusLabel.text = "reply to: " + replytext // setting reply to text
             } else {
-                self.statusLabel.text = "new" // new performance only.
-            }
-            self.performerLabel.text = UserProfile.shared.profile.stageName
-            self.playButton.isEnabled = false
-            self.jamButton.isEnabled = false
-            self.replyButton.isEnabled = false
-            self.instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
-            if let recordView = self.recordView {
+                statusLabel.text = "new" // new performance only.
+            }
+            performerLabel.text = UserProfile.shared.profile.stageName
+            playButton.isEnabled = false
+            jamButton.isEnabled = false
+            replyButton.isEnabled = false
+            instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
+            if let recordingView = self.recordingView {
                 // Updating the color of the performance based on the user defaults.
-                recordView.performance?.colour = UserProfile.shared.profile.jamColour
-                recordView.recordingColour = recordView.performance?.colour.cgColor
-                recordView.openPdFile()
+                recordingView.performance?.colour = UserProfile.shared.profile.jamColour
+                recordingView.recordingColour = recordingView.performance?.colour.cgColor
+                recordingView.openPdFile()
             }
             
         case ChirpJamModes.recording:
             
-            self.navigationItem.title = "recording..."
-            self.statusLabel.text = "recording..."
-            self.playButton.isEnabled = false
-            self.jamButton.isEnabled = false
-            self.replyButton.isEnabled = false
-            self.performerLabel.text = UserProfile.shared.profile.stageName
-            self.instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
+            navigationItem.title = "recording..."
+            statusLabel.text = "recording..."
+            playButton.isEnabled = false
+            jamButton.isEnabled = false
+            replyButton.isEnabled = false
+            performerLabel.text = UserProfile.shared.profile.stageName
+            instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
             
         case ChirpJamModes.playing:
             
             var loadedPerformance = self.performanceViews.last?.performance
             
-            if let recordView = self.recordView {
-                if let performance = recordView.performance {
-                    loadedPerformance = performance
-                }
-            }
-            
-            self.navigationItem.title = loadedPerformance?.dateString()
-            self.statusLabel.text = "Playing..."
-            self.performerLabel.text = loadedPerformance?.performer
-            self.instrumentButton.setTitle(loadedPerformance?.instrument, for: .normal)
-            self.playButton.isEnabled = true
-            self.jamButton.isEnabled = true
-            
-            if self.newPerformance {
-                self.replyButton.isEnabled = false // Should not be able to reply to your own performance
+            if let recordingView = self.recordingView,
+                let performance = recordingView.performance {
+                loadedPerformance = performance
+            }
+            
+            navigationItem.title = loadedPerformance?.dateString()
+            statusLabel.text = "Playing..."
+            performerLabel.text = loadedPerformance?.performer
+            instrumentButton.setTitle(loadedPerformance?.instrument, for: .normal)
+            playButton.isEnabled = true
+            jamButton.isEnabled = true
+            
+            if newPerformance {
+                replyButton.isEnabled = false // Should not be able to reply to your own performance
             } else {
-                self.replyButton.isEnabled = true // reply button enabled in loaded jams.
+                replyButton.isEnabled = true // reply button enabled in loaded jams.
             }
             
         case ChirpJamModes.loaded:
             
             var loadedPerformance = self.performanceViews.last?.performance
             
-            if let recordView = self.recordView {
-                if let performance = recordView.performance {
-                    loadedPerformance = performance
-                }
-            }
-            
-            self.navigationItem.title = loadedPerformance?.dateString()
-            if (!self.newPerformance) {
+            if let recordingView = self.recordingView,
+                let performance = recordingView.performance {
+                loadedPerformance = performance
+            }
+            
+            
+            navigationItem.title = loadedPerformance?.dateString()
+            if (!newPerformance) {
                 // disable the save button, only if it's a loaded performance (not a new one)
-                self.navigationItem.rightBarButtonItem?.isEnabled = false
-                self.replyButton.isEnabled = true // reply button enabled in loaded jams.
+                navigationItem.rightBarButtonItem?.isEnabled = false
+                replyButton.isEnabled = true // reply button enabled in loaded jams.
                 print("JAMVC: Not a new performance, so disabling the save button.")
             } else {
-                self.navigationItem.rightBarButtonItem?.isEnabled = true
-                self.replyButton.isEnabled = false // reply button disabled in loaded jams.
+                navigationItem.rightBarButtonItem?.isEnabled = true
+                replyButton.isEnabled = false // reply button disabled in loaded jams.
 
             }
-            self.statusLabel.text = "Loaded: "
-            self.performerLabel.text = loadedPerformance?.performer
-            self.instrumentButton.setTitle(loadedPerformance?.instrument, for: .normal)
+            statusLabel.text = "Loaded: "
+            performerLabel.text = loadedPerformance?.performer
+            instrumentButton.setTitle(loadedPerformance?.instrument, for: .normal)
             // FIXME: Better way to reset images for ChirpViews
-            for view in self.performanceViews {
+            for view in performanceViews {
                 view.image = view.performance?.image
             }
-            if let recordView = self.recordView {
-                recordView.image = recordView.performance?.image
-            }
-            self.playButton.isEnabled = true
-            self.jamButton.isEnabled = true
+            if let recordingView = recordingView {
+                recordingView.image = recordingView.performance?.image
+            }
+            playButton.isEnabled = true
+            jamButton.isEnabled = true
             
             print("JAMVC: opening Pd file for loaded performance.")
             
         default:
             
-            self.navigationItem.title = "performance"
-            self.statusLabel.text = "new"
-            self.playButton.isEnabled = false
-            self.jamButton.isEnabled = false
-            self.replyButton.isEnabled = false
-            self.performerLabel.text = UserProfile.shared.profile.stageName
-            self.instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
+            navigationItem.title = "performance"
+            statusLabel.text = "new"
+            playButton.isEnabled = false
+            jamButton.isEnabled = false
+            replyButton.isEnabled = false
+            performerLabel.text = UserProfile.shared.profile.stageName
+            instrumentButton.setTitle(SoundSchemes.namesForKeys[UserProfile.shared.profile.soundScheme], for: .normal)
         }
     }
     
     /// Stop playback and cancel timers.
     func stopPlayback() {
         print("JAMVC: Stopping any requested playback")
-        for view in self.performanceViews {
+        for view in performanceViews {
             if let performance = view.performance {
                 performance.cancelPlayback()
             }
         }
-        if let recordView = self.recordView {
-            if let performance = recordView.performance {
-                performance.cancelPlayback()
-            }
+        if let recordingView = self.recordingView,
+            let performance = recordingView.performance {
+            performance.cancelPlayback()
         }
     }
     
     /// Load a ChirpPerformance for playback and reaction (most processing is done in updateUI).
     func load(performance: ChirpPerformance) {
-        self.state = ChirpJamModes.loaded
-        self.recordView?.isUserInteractionEnabled = false
-        self.updateUI()
+        state = ChirpJamModes.loaded
+        recordingView?.isUserInteractionEnabled = false
+        updateUI()
     }
     
     /// Stops the current recording.
     func stopRecording() {
         print("JAMVC: Stopping recording; now loading the recorded performance.")
-        if let lastPerformance = self.recordView!.closeRecording() {
-            if let replytext = self.replyto {
-                lastPerformance.replyto = replytext
-            }
-            self.load(performance: lastPerformance)
+        if let lastPerformance = recordingView!.closeRecording(),
+            let replytext = replyto {
+//            TODO: debug this little if let
+            lastPerformance.replyto = replytext
+            load(performance: lastPerformance)
         }
     }
     

    // MARK: - Navigation
    
    override func prepare(for segue: UIStoryboardSegue, sender: Any?) {
        print("JAMVC: Preparing for Segue. Current state:", self.state)
        // FIXME: save the performance if the timer hasn't run out.
        self.jamming = false // stop jamming.
        if state == ChirpJamModes.recording {stopRecording() }
        if state == ChirpJamModes.playing { stopPlayback() } // stop any possible playback.
        if let barButton = sender as? UIBarButtonItem {
            // TODO: Is this check actually used?
            if savePerformanceButton === barButton {
                print("JAMVC: Save button segue!")
                if let recordView = self.recordView {
                    if let performance = recordView.performance {
                        // Adding performance to clouad
                        appDelegate.performanceStore.addNew(performance: performance)
                        // Reset view controller
                        self.newRecordView()
                        
                        // TODO: Maybe it is best to delete the view controller to save memory?
                        

        // FIXME: I don't think this function is ever actually called. Find out and delete if necessary.
        if sender.source is SettingsTableViewController {
            // Unwinding from settings screen.
            print("JAMVC: unwinding from a settings screen. Current state:", state)
            if (state == ChirpJamModes.new) { // if it's still a new jam, update the sound scheme
                print("JAMVC: updating the Pd file.")
                updateUI()
            }
        }
    }
    
    /// Plays every performance that is loaded into performanceViews and in the recording view.
    func playBackPerformances() {
        // Play loaded performances
        for view in performanceViews {
            if let performance = view.performance {
                performance.playback(inView: view)
                view.playing = true
