Some casting and pointer fixes