Added support for multiple handlers and some   fixes