clean up thread state implementation