Check if handler is nil

It is now possible to pass nil as the handler. Should fix issue #1