I understand now. Nevermind my previous comment. One other question: how do you handle corner cases such as the first frame, which has no previous frame?

Reading this line, I get the impression that self.phones[sequence_id] will be shorter than the actual number of frames.