Prevents callbacks being called multiple times

#18 causes the callback handler to be called multiple times if an error occured.