Some code cleanup before fixing the bug.
Save initial KPI data before session_context comes in

fixes #3014
Merge pull request #3108 from shane-tomlinson/issue_3014_rp_api_kpi

Issue 3104 rp api kpi

@kparlante gave the r+, merging. Close #3104