fix warnings/bugs detected by Visual Studio Code Analysis