coverity#735652 Division or modulo by zero

and

coverity#735651 Division or modulo by zero

Change-Id: I412308ef3e736b1e9c72d1dd3a8d80d2dce92d67
coverity#1242794 Untrusted loop bound

Change-Id: I902a5bf989a8f385994a2f927cce4975b18f06d2
coverity#1242865 Untrusted loop bound

Change-Id: I9dc9cd98d0a02a2867d4c40c7afb7bf873513143
coverity#1242689 Untrusted loop bound

Change-Id: Ie226805ef8d430eb3f7b3abaa54ac3af31f72f7b
coverity#706388 Uncaught exception

Change-Id: I4382645e47ae81e3f15bf69aaa2432dcebd40712
coverity#706401 Uncaught exception

Change-Id: Iacbaf56a23d6f1878c5a5ec6f00db8211cb8ed62
coverity#1242632 Untrusted loop bound

Change-Id: I4ec2e1a21a6a27c31c3308a5f72dbdcb33a62f39
coverity#1242614 Untrusted loop bound

Change-Id: I913e14d30d54b4b370c14017b0702005c23c4fc4