Use single std::vector instance in lieu of heap arrays.

Change-Id: I36820b5c3790998eab922a0fa603ac063972c445
Use scope switch rather than manual on and off.

Change-Id: Ia4072339b6f1fd4b929d891dcc8f3bb3e2403d5e