Factor out frame calculation code
Track frame changes and update the overlay accordingly