Fixed several warnings (mainly casting)