kqueue support

I forked ayutthaya's kqueue's changes and made modifications to clean up the code and fix bugs I found in my testing. In addition, I made changes to allow the code to compile on FreeBSD. Please let me know if there are further changes you'd like to this code so it can be incorporated upstream. Thanks!