Bug fixes and code cleanup identified by valgrind and clang.

This contains some fixes for memory corruption or other risky code identified by valgrind/clang. I tried to avoid being pedantic by limiting the errors fixed only to those I thought could cause real damage.

Please check the "CHECK THIS" comment in GSmath.h; I'm 99% sure this is a bug, but perhaps there is some weird GL thing I am overlooking.

Note: The "x1 ^= (x2 ^= (x1 ^= x2));" line uses sequence points incorrectly, and is a very confusing way of writing "swap" in the first place.