Rewind stream before processing, remove unused code