fix bug with application not terminating properly

it now checks correctly for waiting calls before deciding to end
initialize workers in a loop

handy for when we don't know the number of processors at compile time :-P
set call state in more C functions