Fix comment
Fix calculation of the total stream numbers
Fix memory leak
Add the check code of null pointer