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

        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
                    }
                }
                
            }
        }
        

            let lastTimestamp = presentationTimestamp + duration
            
            self._audioQueue.async {
                if let audioInput = self._audioInput,
                    audioInput.isReadyForMoreMediaData && audioInput.append(adjustedBuffer) {
                    self._lastAudioTimestamp = lastTimestamp
                    
                    if !self.currentClipHasVideo {
                        self._currentClipDuration = lastTimestamp - self._startTimestamp
                    }
                    
                    self._currentClipHasAudio = true
                    
                    completionHandler(true)
                    return
                }
                completionHandler(false)
            }
