clang warning fixes, including 2 bug fixes