Refactor addNewKeyframe.