Fix some compilation errors and warnings.