[Demonstration 1]

[Buggy Method]
private void spotNGrams(Blackboard blackboard, DocumentComponent component) {
    // are we a sentence? if yes, spot the nGrams
    if (component.hasComponents()) {
        List<DocumentComponent> children = component.getComponents();
        // if not and we're a section, traverse the document tree recursively
        for (DocumentComponent child : children) {
            spotNGrams(blackboard, child);
        }
    } else {
        String sentenceText = component.getText();
        Sentence sent = (Sentence) component;
        List<Token> allWords = sent.getTokens();
        // build the token start and end substring indexes in the input string
        int[] startIndexes = new int[allWords.size()];
        int[] endIndexes = new int[allWords.size()];
        // track how much text we've already scanned
        int searchWordFrom = 0;
        for (int i = 0; i < allWords.size(); i++) {
            startIndexes[i] = sentenceText.indexOf(allWords.get(i).getText(), searchWordFrom);
            endIndexes[i] = startIndexes[i] + allWords.get(i).getText().length();
            searchWordFrom = endIndexes[i];
        }
        // we keep n buffers of the last n words scanned
        // (where n = maxngramsize ). The first buffer is of size 1,
        // the second of size 2, ... and so on.
        // then, we compare these buffers with the valid known PoS patterns
        // and save the ngram if it matches.
        ArrayList<Token>[] lastReadBuffers = new ArrayList[maxGramSize];
        for (int size = 0; size < maxGramSize; size++) {
            lastReadBuffers[size] = new ArrayList<>();
        }
        for (int i = 0; i < allWords.size(); i++) {
            Token word = allWords.get(i);
            for (int size = 0; size < maxGramSize; size++) {
                // if the buffer is not full, fill it
                if (lastReadBuffers[size].size() < size + 1) {
                    lastReadBuffers[size].add(word);
                } else {
                    // else, cut the head and put the new word at the tail
                    lastReadBuffers[size].remove(0);
                    lastReadBuffers[size].add(word);
                }
                if (i >= size) {
                    // if the pattern is in the database AND contains a noun, then
                    // it's a nGram that could be a keyphrase.
                    int nounValue = checkGramNounValue(lastReadBuffers[size]);
                    if (nounValue > 0) {
                        // the identifier is the stem of the words
                        String identifier = lastReadBuffers[size].get(0).getText();
                        for (int k = 1; k < lastReadBuffers[size].size(); k++) {
                            identifier = identifier + " " + lastReadBuffers[size].get(k).getStem();
                        }
                        identifier = identifier.toLowerCase();
                        int startIndex = startIndexes[i - (lastReadBuffers[size].size() - 1)];
                        int endIndex = endIndexes[i];
                        Keyphrase g = new Keyphrase(identifier, lastReadBuffers[size], sentenceText.substring(startIndex, endIndex));
                        g.putFeature(new FeatureAnnotation(NOUNVALUE, ((float) nounValue) / (float) g.getTokens().size()));
                        blackboard.addGram(component, g);
                    }
                }
            }
            // for
        }
        // for
    }
    // if
}

[Buggy Hunk]
String identifier = lastReadBuffers[size].get(0).getText();

[Patch]
String identifier = lastReadBuffers[size].get(0).getStem();

[Demonstration 2]

[Buggy Method]
public void add(Track track) {
    player.addSong(track);
    if (!playlistInit) {
        playlistInit = true;
    }
}

[Buggy Hunk]
public void add(Track track) {

[Patch]
void add(Track track) {

[Demonstration 3]

[Buggy Method]
@Override
public void onMessageReceived(Chat chat, Message message) {
    Date date = new Date();
    message.setSubject(MessageDirection.INCOMING);
    ArrayList<Haber.HaberListener> corpses = new ArrayList<>();
    for (Haber.HaberListener listener : getHaberListeners()) {
        if (listener == null)
            corpses.add(null);
        else if (listener != this)
            listener.onMessageReceived(chat, message);
    }
    for (Haber.HaberListener listener : corpses) removeHaberListener(listener);
    if (!chatRooms.contains(chat) && chat != null)
        chatRooms.add(chat);
    //if activity isn't shown => haber is in background
    if (HaberActivity.getInstance() == null) {
        if (chat != null) {
            if (message.getFrom() != null) {
                haberCounter.addPm(message.getFrom());
                refreshNotification();
            }
        } else if (message.getBody() != null) {
            if (!Haber.IsGuest()) {
                if (message.getBody().toUpperCase().contains(Haber.getUsername().toUpperCase())) {
                    haberCounter.mentionCounter++;
                    refreshNotification();
                }
            } else {
                if (message.getBody().toUpperCase().contains(Haber.getUsername().substring(1).toUpperCase())) {
                    haberCounter.mentionCounter++;
                    refreshNotification();
                }
            }
        }
    }
    counter++;
    if (counter >= 25) {
        if (AdvancedPreferences.ShouldVibrate(this) && AdvancedPreferences.ShouldVibrateInService(this) && !HaberActivity.InstanceExists()) {
            boolean shouldVibrate = false;
            if (chat == null) {
                if (message.getBody() != null) {
                    if (AdvancedPreferences.ShouldVibrateOnReply(this)) {
                        String mark = "@" + Haber.getUsername();
                        if (message.getBody().toUpperCase().contains(mark.toUpperCase())) {
                            ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(100);
                            shouldVibrate = true;
                        } else if (Haber.IsGuest()) {
                            mark = "@" + Haber.getUsername().substring(1);
                            if (message.getBody().toUpperCase().contains(mark.toUpperCase())) {
                                ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(100);
                                shouldVibrate = true;
                            }
                        }
                    }
                }
            } else {
                shouldVibrate = true;
            }
            if (shouldVibrate)
                ((Vibrator) getSystemService(Context.VIBRATOR_SERVICE)).vibrate(100);
        }
    }
    long delay = ((new Date()).getTime() - date.getTime());
    Debug.log("onMessageReceived - " + delay + " ms");
    if (delay > 300) {
        Debug.log("Slow frame detected, data:");
        Debug.log(String.format("Counter: %d\n chat is null: %d\ncorpses.length(): %d\nMessage: %s", counter, (chat == null) ? 1 : 0, corpses.size(), message.toXML().toString()));
    }
}

[Buggy Hunk]
if ( counter >= 25 ) {

[Patch]
if ( counter >= 25 && !message.getSubject().equals(MessageDirection.OUTGOING)) {