Fix50d

Excellent! But try to avoid vars. Something like this will be better:
```
val (adjustedMaxAmount, adjustedMinAmount) =
  if (  ) {
    (0, maxAmount)
  }
```