fixed ugly bug which caused many strange hangs