Make it work for Windows and Mac OS

Hi Ludovic,

I've updated your code to make it compile and work under Mac OS and Windows.
Moreover I've took the liberty to fix some compiler warnings and memory leaks.

Please let me know what you think.

Best regards
Rolf