Fixed unclosed stream.
Added dmalloc support.