Add wait call for background and foreground processes (i.e. zombie cleanup). Everything appears to work. Will test more.