Refs #214, #221, #246. Fixed the getrf overflow bug on Windows.

I used a smaller threshold since the stack size is 1MB on windows.