Memfixes

Fixes for issues flagged by Dr.Memory and the MSVC static analysis tool, along with a few misc code hygiene improvements
We've been doing it like this to handle this situation, I'll use the lines mentioned above:
```C++
const size_t errorSize = 4096;
wchar_t error[errorSize];
_swprintf_l(error, errorSize, L"Unable to load game library: %s. Please make sure it exists and the latest DirectX is installed.", _get_current_locale(), dllName.c_str());
```