Fix Windows build, improve error reporting (#565)