Refactor for a more functional style, allowing session start tracking.