Fixes for warnings found by static analysis build into VS2012

 - The pragma disables suppress false positives from the static analysis
 - The other fixes fix real problems found by the static analysis