Move this code to the context class.

Change-Id: I387dba24993d418a2b3923eac992ad2506229704
Scope reduction.

Change-Id: Ic0cb74d220dccdcb4f607f4883b9b7fdf86bb080