http and thread refactoring part I
more shenanigans around threading