fixed weird threading bugs. note to self: have not understood python threads