fixed clang errors and some warnings