Refactor the non-portable parts of Butler thread into new functions