Fixed GCC warnings about incompatible type conversions

Fixed GCC warnings about incompatible type conversions and some related errors.