fix ms bugs and missing includes