Corrected some cast warnings