replace WAIT condvar with semaphore
clean up syscall.c
rename and move some structs