next attempt to fix the race in wait_some
applied fix to several other bug occurences
changed variable names to be consistent
Merge pull request #1232 from STEllAR-GROUP/fixing_wait_some

Fixing race in wait_xxx