Separated stream handeling to different method.
Removed unused variable.