         MusicPlayerSetSequence(musicPlayer, sequence)
     }
     
-    //inits the sequence with a midi file
-    public convenience init(filename:String){
+    /// Initialize the sequence with a MIDI file
+    public convenience init(filename: String) {
         self.init()
         loadMidiFile(filename)
     }
     
-    //inits the sequence with a midi file and audioengine
-    public convenience init(filename:String, engine:AVAudioEngine){
+    /// Initialize the sequence with a midi file and audioengine
+    public convenience init(filename: String, engine: AVAudioEngine) {
         self.init()
         avSeq = AVAudioSequencer(audioEngine: engine)
         loadMidiFile(filename)
     }
     
-    //set loop functionality of entire sequence
+    /// Set loop functionality of entire sequence
     public func loopToggle(){
         (loopEnabled ? loopOff() : loopOn())
     }
-    public func loopOn(){
-        setLoopInfo(length, numLoops: 0)
+    
+    /// Enable looping for all tracks
+    public func loopOn() {
+        setLoopInfo(length, numberOfLoops: 0)
         for track in avSeq.tracks{
             track.loopingEnabled = true
             track.loopRange = AVMakeBeatRange(0, self.length)
         }
         loopEnabled = true
     }
-    public func loopOff(){
-        setLoopInfo(0, numLoops: 0)
+    
+    /// Disable looping for all tracks
+    public func loopOff() {
+        setLoopInfo(0, numberOfLoops: 0)
         for track in avSeq.tracks{
             track.loopingEnabled = false
         }
         loopEnabled = false
     }
-    //set looping of all tracks
-    public func setLoopInfo(duration:Double, numLoops:Int){
+    
+    ///  Set looping duration and count for all tracks
+    public func setLoopInfo(duration: Double, numberOfLoops: Int) {
         let size:UInt32 = 0
-        let num:Int32 = Int32(numLoops)
         let len = MusicTimeStamp(duration)
-        var loopInfo = MusicTrackLoopInfo(loopDuration: len, numberOfLoops: num)
-        for( var i = 0; i < self.numTracks; ++i){
+        var loopInfo = MusicTrackLoopInfo(loopDuration: len, numberOfLoops: Int32(numberOfLoops))
+        for( var i = 0; i < self.numberOfTracks; ++i){
             var musicTrack = MusicTrack()
             MusicSequenceGetIndTrack(sequence, UInt32(i), &musicTrack)
             MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_LoopInfo, &loopInfo, size)
         }
     }
-    //set length of all tracks
-    public func setLength(length:Double){
+    /// Set length of all tracks
+    public func setLength(length: Double) {
         let size:UInt32 = 0
         var len = MusicTimeStamp(length)
-        for( var i = 0; i < self.numTracks; ++i){
+        for( var i = 0; i < self.numberOfTracks; ++i){
             var musicTrack = MusicTrack()
             MusicSequenceGetIndTrack(sequence, UInt32(i), &musicTrack)
             MusicTrackSetProperty(musicTrack, kSequenceTrackProperty_TrackLength, &len, size)

        initTracks()
    }
    
    func initTracks(){
        tracks.removeAll()
        for( var i = 0; i < self.numTracks; ++i){
            var musicTrack = MusicTrack()
            MusicSequenceGetIndTrack(sequence, UInt32(i), &musicTrack)
            tracks.append(AKMusicTrack(musicTrack: musicTrack))

        return Double(length)
    }
    
    /// Play the sequence
    public func play() {
//        MusicPlayerStart(musicPlayer)
        do{
            try avSeq.start()
