Fix checks in loop (and remove clang warnings)