bug fixes
compile with clang
bug fixes for clang warnings