thread config throughout

this will make it easier to use this as a lib in the future