* fixing the task detach cleanup bugs and made it safe
* optimising the cleanup sequence for hspace and hproc
* fixing other bugs in the cleanup sequence