Add retry options

I've added support for retrying. This is disabled by default, but can be enabled with a boolean, or with options set.