fix bug in waitforqueues
fix bug in process stopping logic
release 3.1.7: bugfixes