Minor C++ improvements

This is just some stuff found with clang-analyzer