tor patch and refact