The secondary search at the gate is extremely common on US bound flights from South and Central America. So hint, if you want to bring drinks or something else they'd not allow, wear a jacket and put it in your inside pocket, they never do a body pat at the gate. I've done that at numerous Latin American airports, including LIM.
The other issues you described though don't surprise me. If AV Peru was still operating it'd have been on them and you'd have had a smoother experience. I can't 100% swear to it now but I'm pretty sure there was interline transfer domestic to INT when AV Peru existed, but if not I suspect it would have been for narcotics checks more than lack of ability and that's still a possible reason for what you just experienced. Unfortunately a lot of narcotics smuggling comes out of Peru so they do a lot of profiling and checks in the international departures hall.