it also messes up local pointers pointing to local variables after wait().