Add comments and improve remote-fetch algorithm