         private var _lastBufLen : Number;
         private var _lastDuration : Number;
         private var _lastMediaTimeUpdate : int;
+        /* overlapping fragment stuff */
+        private var _overlappingTags : Vector.<FLVTag>;
+        private var _overlappingStartPosition : Number;
+        private var _overlappingMinPTS : Number;
 
 
         public function StreamBuffer(hls : HLS, audioTrackController : AudioTrackController, levelController : LevelController) {

            _videoTags = new Vector.<FLVData>();
            _metaTags = new Vector.<FLVData>();
            _headerTags = new Vector.<FLVData>();
            _fragMainLevel = _fragAltAudioLevel = _fragMainLevelNetStream = -1;
            _fragMainSN = _fragAltAudioSN = _fragMainSNNetStream = 0;
            FLVData.refPTSMain = FLVData.refPTSAltAudio = NaN;

                _clipBackBuffer(HLSSettings.maxBackBufferLength);
            }
        }

        /* filter incoming tags overlapping with existing buffer */
        private function filterOverlappingTags(tags : Vector.<FLVTag>, overlap : Number) : Vector.<FLVTag> {
            var aacIdx : int,avcIdx : int,disIdx : int,metIdx : int, videoIdx : int,audioIdx : int, lastIdx : int;
            var first_pts : Number = tags[0].pts + 1000*overlap;
            var flvData : FLVData = getNextTag(false);
            if(flvData) {
                first_pts = Math.max(first_pts,flvData.tag.pts);
            }
            var filteredTags : Vector.<FLVTag>=  new Vector.<FLVTag>();
            var filteredDuration : Number = 0;
            aacIdx = avcIdx = disIdx = metIdx = videoIdx = audioIdx = lastIdx = -1;
            for (var i : int = 0; i < tags.length; i++) {
                var tag : FLVTag = tags[i];
                switch(tag.type) {
                    case FLVTag.DISCONTINUITY:
                        // retrieve last DISCONTINUITY tag before first_pts
                        if (tag.pts <= first_pts)
                            disIdx = i;
                        break;
                    case FLVTag.METADATA:
                        // retrieve last METADATA tag before first_pts
                        if (tag.pts <= first_pts)
                            metIdx = i;
                        break;
                    case FLVTag.AAC_HEADER:
                        // retrieve last AAC_HEADER tag before first_pts
                        if (tag.pts <= first_pts)
                            aacIdx = i;
                        break;
                    case FLVTag.AVC_HEADER:
                        // retrieve last AVC_HEADER tag before first_pts
                        if (tag.pts <= first_pts)
                            avcIdx = i;
                        break;
                    case FLVTag.AVC_NALU:
                        // retrieve first keyframe after first_pts
                        if (videoIdx == -1 && tag.pts > first_pts && tag.keyframe) {
                            lastIdx = videoIdx = i;
                            CONFIG::LOGGING {
                                Log.debug("found AVC_NALU_K after overlap @PTS:" + tag.pts);
                            }
                        } else if (videoIdx >=0) {
                            lastIdx = i;
                        }
                         break;
                    case FLVTag.MP3_RAW:
                    case FLVTag.AAC_RAW:
                        // retrieve first frame after first_pts
                        if (audioIdx == -1 && tag.pts >  first_pts) {
                            lastIdx = audioIdx = i;
                        } else if (audioIdx >=0) {
                            lastIdx = i;
                        }
                        break;
                    default:
                        break;
                }
            }

            if(lastIdx >=0) {
                filteredDuration = tags[lastIdx].pts - first_pts;
                CONFIG::LOGGING {
                    Log.debug("filterOverlappingTags : filtered duration:" + filteredDuration);
                }
            }

            if((videoIdx >= 0 || audioIdx >=0) && filteredDuration > 500) {
                // modify PTS for DISCONTINUITY/METADATA/AAC_HEADER/AVC_HEADER tag
                // and push as filtered tag
                if(disIdx >=0) {
                    tags[disIdx].pts = tags[disIdx].dts = Math.min(tags[audioIdx].dts,tags[videoIdx].dts);
                    filteredTags.push(tags[disIdx]);
                }
                if(metIdx >=0) {
                    tags[metIdx].pts = tags[metIdx].dts = Math.min(tags[audioIdx].dts,tags[videoIdx].dts);
                    filteredTags.push(tags[metIdx]);
                }
                if(aacIdx >=0) {
                    tags[aacIdx].pts = tags[aacIdx].dts = tags[audioIdx].dts;
                    filteredTags.push(tags[aacIdx]);
                }
                if(avcIdx >=0) {
                    tags[avcIdx].pts = tags[avcIdx].dts = tags[videoIdx].dts;
                    filteredTags.push(tags[avcIdx]);
                }

                for (i= 0; i < tags.length; i++) {
                    tag = tags[i];
                    switch(tag.type) {
                        case FLVTag.AVC_NALU:
                            // push all AVC NALU located after videoIdx
                            if (videoIdx >= 0 && i >=  videoIdx) {
                                filteredTags.push(tag);
                            }
                             break;
                        case FLVTag.MP3_RAW:
                        case FLVTag.AAC_RAW:
                            // push all audio tags located after audioIdx
                            if (audioIdx >=0 && i >=  audioIdx) {
                                filteredTags.push(tag);
                            }
                            break;
                        default:
                            break;
                    }
                }
            } else {
                CONFIG::LOGGING {
                    Log.debug("filterOverlappingTags: only overlapping tags found");
                }
            }
            CONFIG::LOGGING {
                Log.debug("filterOverlappingTags: filtered " + filteredTags.length + " out of " + tags.length);
                // for (i= 0; i < filteredTags.length; i++) {
                //     Log.debug("filteredOverlappingTags: filtered " + filteredTags[i].typeString + '/' + filteredTags[i].dts + '/' + filteredTags[i].pts);
                // }
            }
            return filteredTags;
        }


        /* filter/tweak tags to seek accurately into the stream */
        private function seekFilterTags(tags : Vector.<FLVData>, absoluteStartPosition : Number) : Vector.<FLVData> {
