Remove globals from complex methods

Extending class will more easily be able to use those methods with
their own variables.

Change-Id: Ib8969ca9f42581224bd32f8da49c3358d3aec3f7
Merge "Remove globals from complex methods"