Refactored farm code.