Refactoring uithread to make it do no allocations under normal load.