Improve robustness of river creation code