Could you add some tests about reading/writing invalid streams? Just want to make sure that everything is cleaned up just fine.