coverity#704523 Division or modulo by zero

and coverity#704522

Change-Id: Ieccd4c4e16a14ea68f8b4879232924a1d05e29ea
coverity#1202783 Division or modulo by zero

Change-Id: I183416ad3db39108e52c1e69b60fb547448b21a8
coverity#1202784 Division or modulo by zero

Change-Id: I982b72abd92584b9ed97de593c17f2cf0b8b3667
coverity#1202785 Division or modulo by zero

Change-Id: I5ede52be101a7603d4edad30b7a1f8ee0fc4b07d
coverity#1202830 Out-of-bounds access

Change-Id: I25edea176b69c1c1f87bdbff790a39298a813660