Fix bad casts and uninitialized vars.