fixed many bugs with retry, fixes #2