Code cleanup.

Avoid repetetive boilerplate code by using helper methods.

Change-Id: Id3ce8d07d35d59c08cbc67fa35bbf6daa67c9608
Automatic translation import

Change-Id: If226d8f4684929f5515fafdc67b4013729206046
Merge "Code cleanup." into cm-11.0
Merge remote-tracking branch 'upstream/cm-11.0' into cm-11.0