Cloning IR remote codes

I have tried various IR libraries -- and eventually; they all say "unknown" to a code that was previously known.

Often times I'm getting a code that is not recognized; so I have to hit it over and over again until it is recognized. the values that it sees are never the same. Sometimes not even the same byte count (one code will be 7, then next 32, the next 9) so I can't easily average the codes as I've seen suggested.

What is the best way to "learn" a code that isn't transmitted reliably? I'd say the majority of time I get "unknown" and a series of bytes; sometimes those bytes are the same count and similar (2030 vs 2035) sometimes they aren't (2030 vs 913); other times the byte count is different (32 vs 7); more annoyingly I get 'unknown' and then "nec: repeat ignored" so I don't get a full code...

I've tried 3 different IR libraries... all similar; so I suspect this isn't an uncommon issue. suggestions?