Improved stream state checking