     var passThroughTimeRanges:[NSValue] = [NSValue]()
     var transitionTimeRanges:[NSValue] = [NSValue]()
     var cursorTime = kCMTimeZero
-            
-    for (var i = 0 ; i < assetsWithVideoTracks.count ; ++i)
-    {
-        let asset = assetsWithVideoTracks[i]
-        var timeRange = CMTimeRangeMake(cursorTime, asset.duration)
-        
-        if i > 0 {
+    
+    for (index, videoAsset) in enumerate(assetsWithVideoTracks) {
+        var timeRange = CMTimeRangeMake(cursorTime, videoAsset.duration)
+        if index > 0 {
             timeRange.start = CMTimeAdd(timeRange.start, transDuration)
             timeRange.duration = CMTimeSubtract(timeRange.duration, transDuration)
         }
         
-        if i + 1 < assetsWithVideoTracks.count {
+        if index + 1 < assetsWithVideoTracks.count {
             timeRange.duration = CMTimeSubtract(timeRange.duration, transDuration)
         }
         
         passThroughTimeRanges.append(NSValue(CMTimeRange: timeRange))
-        cursorTime = CMTimeAdd(cursorTime, asset.duration)
+        cursorTime = CMTimeAdd(cursorTime, videoAsset.duration)
         cursorTime = CMTimeSubtract(cursorTime, transDuration)
-        // println("cursorTime.value: \(cursorTime.value)")
-        // println("cursorTime.timescale: \(cursorTime.timescale)")
         
-        if i + 1 < assetsWithVideoTracks.count {
+        if index + 1 < assetsWithVideoTracks.count {
             timeRange = CMTimeRangeMake(cursorTime, transDuration)
-            // println("timeRange start value: \(timeRange.start.value)")
-            // println("timeRange start timescale: \(timeRange.start.timescale)")
             transitionTimeRanges.append(NSValue(CMTimeRange: timeRange))
         }
     }
+
     return (passThroughTimeRanges, transitionTimeRanges)
 }
 

    
    var cursorTime = kCMTimeZero
    
    for (var i = 0 ; i < assetsWithVideoTracks.count ; ++i) {
        let trackIndex = i % 2
        let currentTrack = videoTracks[trackIndex]
        let assetTrack = assetsWithVideoTracks[i].tracksWithMediaType(AVMediaTypeVideo)[0] as AVAssetTrack
        let timeRange = CMTimeRangeMake(kCMTimeZero, assetsWithVideoTracks[i].duration)
        currentTrack.insertTimeRange( timeRange,
                             ofTrack: assetTrack,
                              atTime: cursorTime,
                               error: nil)
        
        // Overlap clips by tranition duration // 4
        cursorTime = CMTimeAdd(cursorTime, assetsWithVideoTracks[i].duration)
        cursorTime = CMTimeSubtract(cursorTime, transitionDuration)
    }
    
    // Currently leaving out voice overs and movie tracks. // 5
}

// Function to calculate both the pass through time and the transition time ranges

             assetsWithVideoTracks: movieAssets)

// Create the passthru and transition time ranges.
// let timeRanges = calculateTimeRanges(transitionDuration: transDuration,
//                                  assetsWithVideoTracks: movieAssets)

let timeRanges = calculateTimeRanges(
    transitionDuration: transDuration, assetsWithVideoTracks: movieAssets)

// Create the instructions for which movie to show and create the video composition.
let videoComposition = buildVideoCompositionAndInstructions(
