Prevent callback to be invoked multiple times.
Merge pull request #5 from sapegin/fixmultiplecallbacks

Callback invoked two times on error