max_generation parameter was not working correctly.