     /// Removes the last recorded clip for a session, "Undo".
     public func removeLastClip() {
         self.executeClosureSyncOnSessionQueueIfNecessary {
-            if self.clips.count > 0 {
-                if let clipToRemove = self.clips.last {
-                    self.remove(clip: clipToRemove)
-                }
+            if !self._clips.isEmpty,
+               let clipToRemove = self.clips.last {
+                self.remove(clip: clipToRemove)
             }
         }
     }

        var frameDuration = minFrameDuration
        let offsetBufferTimestamp = timestamp - self._timeOffset
        
        if let videoConfig = self._videoConfiguration, let timeScale = videoConfig.timescale {
            if timeScale != 1.0 {
                let scaledDuration = CMTimeMultiplyByFloat64(duration, timeScale)
                if self._currentClipDuration.value > 0 {
                    self._timeOffset = self._timeOffset + (duration - scaledDuration)
                }
                frameDuration = scaledDuration
            }
        }
        
        if let videoInput = self._videoInput, let pixelBufferAdapter = self._pixelBufferAdapter {
            if videoInput.isReadyForMoreMediaData {
                
                var bufferToProcess: CVPixelBuffer? = nil
                if let customImageBuffer = customImageBuffer {
                    bufferToProcess = customImageBuffer
                } else {
                    bufferToProcess = pixelBuffer
                }
                
                if let bufferToProcess = bufferToProcess {
                    if pixelBufferAdapter.append(bufferToProcess, withPresentationTime: offsetBufferTimestamp) {
                        self._currentClipDuration = (offsetBufferTimestamp + frameDuration) - self._startTimestamp
                        self._lastVideoTimestamp = timestamp
                        self._currentClipHasVideo = true
                        completionHandler(true)
                        return
                    }
                }
                
            }
        }
        

    /// - Parameter removeFiles: When true, associated files are also removed.
    public func removeAllClips(removeFiles: Bool = true) {
        self.executeClosureAsyncOnSessionQueueIfNecessary {
            while !self._clips.isEmpty {
                if let clipToRemove = self._clips.first {
                    if removeFiles {
                        clipToRemove.removeFile()
