added setHandlers function and changed to use it. added some comments. added reset method.