Use unsigned short instead of int in a few places that makes sense to do so.
Be consistent with function's variables.
Fix possible NULL pointer dereference.
disable a couple more /analyze warnings for VS2012
include/atl: remove extra arguments from format strings and use the right field type specifier.
Use the right field type specifier in function calls.

(/analyze warning C6340)