kqueue<->inotify flag conversion improvements and bugfixes

First 4 changes duplicates previous pull-request :-(