work arround msvc bugs and fix some warnings