fixed mutex handling for windows. Fixes #466