Fixing little problem where streams might not be closed properly.