applied fixes for windows from http://stackoverflow.com/a/24763080/3922441