latest from upstream

including my patches with windows support