clsed a whole lot of resource leaks