Adapt from FarmManager repository