resource leaks fixed.