Fixes thread freezing bug.