Thread clean-up

Mostly done with that.