STYLE: Reduce scope of local variables where possible

Change-Id: I5a901b23ac3609a14a284efca812a184a738547e
Merge topic 'ReduceScopeOfVariables'

3955108 STYLE: Reduce scope of local variables where possible