Hand1: Your raise on the flop was OK, once you were reraised I would call, if he fires again on the turn I fold this, your hand is not that great, since he limped from the SB he could have x9 with the x outkicking you, or an 8, you have a nice chip lead and I would not risk it in this spot.

Hand2: You played it fine, he could pull this with A5, higher PP etc.., it is just bad luck you ran into trips with a better kicker