Put traps to prevent two possible divide by 0 errors. Change-Id: Ia415b945244253dcdd12f54f1f157f9ca8c94d6b