fixed some leaving the streams open problem, but more fixed are needed...