Fix some bugs under Windows