Fixed compiler warnings with some casts and little changes like that