Split huge method into more reasonable chuncks

Change-Id: Ifb13a6976e13610a26315c5bb4cd136129d14555