just a bit of cleanup, add retry functionality, and retry limit