Andrew s/fix windows func

Fix some bugs