fixed gcc 4.1 warnings with explicit casts