improved detect_mem on Windows, experimenting with others, other minor changes