Adds reset historyIndex in clear() method.