Fixed bug with closing streams and added main container