I just did an engine replacement and had similar demons. The fix for mine was to move the ground for the fuel injectors to its own stud on the back of the engine. I also believe that the 5.7 uses 2 knock sensors instead of one like the 5.0 mpi. There may also be the cam position sensor that( I believe) plugs into the distributor. My 5.0 mpi does not use a cam position sensor, only a crank position sensor, BTW, on my new long block, the CPS was bad too! I just did a 5.0 mpi long block swap and mine would crank, run for a bit then cough through the throttle body and die. It was also leaving the injectors open and pulling fuel into the crankcase. It’s not that bad-you can figure it out. It’s just a machine.