enforce coding standard: explicit casts
Improved stat accumulation and context names