Fix formatting and some refactor.
Update Mingw-builds version to 4.0.0