Various fixes

Automatically clean threads after posting a new one.
Fix crash when posting returns error.