rewrite a few things for windows compilation