Fixed some windows related bugs