Algorithm is functional. Alignment of events with times is slightly off.