Bug Fix

* removed a unused struct member
* prevent closing stream multipul times
* make sure ctx will be freed in any case