warnings: Add explict casts to silence many compiler warnings about sign comparisions.