Fix resources node planting to be safer and to consider edge cases

Change-Id: I18facdb5a2a96cceada40584232a65e18ef12afa
Merge "Fix resources node planting to be safer and to consider edge cases"