Improved stream handling and stream end handling
fixed typo in class name