Fixed bug where stuf is not properly closed