IMHO, the first hand was played correctly, except for the initial postflop bet. The flop showed a diamond draw, and your $20 bet gave anyone on that draw good pot odds. If it was me, I would have bet at least the pot, if not shoving all-in.

The second hand, I would have folded to the preflop raise. You are under the gun with suited K-rags. Not enough to call a 4xBB bet, I think.