Fix retry, minor code improvement