Fixed some compile warnings
Fixed crash on Windows