Reduced the max indentation level to five. Spilt functions to several smaller functions. Only a few functions were split in this commit. Rest need to be done in future commits. Change-Id: I1c9dcf3ae12edef6bcce37023f93d062705e0142 CRs-Fixed: 2098511