- fixed resource leak
- use power of two size
- restore stream settings