Memfixes

Fixes for issues flagged by Dr.Memory and the MSVC static analysis tool, along with a few misc code hygiene improvements
You often have an "array count" macro that does this generically like `sizeof(a)/sizeof(a[0])`. I didn't see anything like this in torque - is there a mem utils header or something to that effect where this could go?