Significantly simplify the kqueue multiplexer implementation

- Use vectors for managing events and changes to sockets instead of nasty arrays
- Fix detection of kqueue on BSD systems since most BSD systems implement poll() as well