Enabled Microsoft static code analysis, and fixed all of the issues.
Fixed the setting of the trap flag for 32bit systems.
Added better handling of the trap on branch flag.