Improved thread control (unfinished)