cleaned up some stuff, also made a chnage to the threading