could get a multimeter and check the wiring harness for any tears in the wires etc. if its coming back on it’s got to either be faulty parts, faulty wiring and something else in that system is also faulty. what are the exact codes coming up?
could be seals or maybe the thermostat is faulty, when and where is it leaking? is it leaking out the housing or where the housing attaches to pipes? is it leaking all the time, with the engine off and cold is it still leaking?
just get a rebuilt one of the current engine you've got, if it’s been done by a decent garage you will get some kind of warranty with it and it will fit straight in with no issues to face and will make it easier for fixing in the future.
first thing double check the battery has been put in the right way round, honestly so many people put it back wrong. Check the buttons on the circuit board aren’t damaged or falling off and no signs of water damage. This works with the generation before you car defiantly and may work for yours if it needs reprogramming, fingers crossed it works for you. 1. Switch ignition ON. 2. Within 4 seconds press the LOCK or UNLOCK button of the first remote transmitter. 3. Within 4 seconds switch ignition OFF. 4. Within 4 seconds switch ignition ON. 5. Within 4 seconds press the LOCK or UNLOCK button of the first remote transmitter. 6. Within 4 seconds switch ignition OFF. 7. Within 4 seconds switch ignition ON. 8. Within 4 seconds press the LOCK or UNLOCK button of the first remote transmitter. 9. Within 4 seconds switch ignition OFF. 10. Within 4 seconds switch ignition ON. 11. Within 4 seconds press the LOCK or UNLOCK button on the first remote transmitter. 12. The doors will LOCK and...
either get the parts replaced by a garage, check a workshop manual or ask a VW dealership to get you a quote and the part numbers are usually on the invoice then source them off the web yourself. I would replace the parts for genuine ones first that have been replaced before and see if anything changes with you other issues, VAG cars are wired strangely and wouldn’t surprise me if it fixed one of them.
which all those faults my guess would either be a faulty connecter from one of the wiring looms into the fuse box or a faulty ECU, any signs of water damage on any of the electrical system? does the car run and can you drive it? a garage or auto electrician would be able to trace the problem quite easy having access to the car with all those issues your having.
do you have any problems starting it or just when its running? double check the basics like plugs, vacuum leaks and airway for blockages, check fuse box for any loose or blown fuses and relays. Compression test, fuel pressure (check injectors, pump and pressure test), check the wiring harness for the ignition system for any breakages or liquid getting into any connectors, faulty MAF sensor. couple of things to check hopefully they’ll bring something up and you can fix it. bad timing could also cause the car to randomly stall but would have others symptoms too, if you've replaced all those parts though it might be worth checking it just in case.