MSVC 2013 compatibility: fix memory corruption.

The quality of this compiler just reached a new low. Getting memory
corruption just because I didn't include the header which isn't needed
by any other compiler?!  What?!
Be more defensive in getting max texture slot count.
Merge branch 'master' into compatibility