Cast max_retries value to int and improve logging