fixed windows access problems due to unclosed file handles