Move total out of #if and add comment about its safeness (Chris' suggestion)