Bug fixes in kqueue