Select invalid geometry fixes

Cherry-picked two invalid geometry fixes.