Misc fixes for install and mingw build

Here are some misc fixes, commit messages explain in further detail.