If, as seems to be the case, byte-compile-keep-pending is only used for top-level forms, then this patch may even be correct. Does it solve your problems? It still seems to generate far bigger bytecode chunks than the 300 cutoff would imply but that's perhaps just a matter of calling the function in more places.