Destructor updated.
IO blocking code moved and rewritten.