Added thanks to Christoph for patches for Win platforms.