MinGW compatability, tchars, and a bit of cleanup