When I flashed CM13 and CM14 I also had constant black screens and phone shut down randomly.
And because I wanted to prove to myself that these are not hardware faults I reverted to stock rom.
I flashed FTF image with Flashtool. I had to use older flashtool version as the latest couldn't finish the process and broke with errors.
Flashtool 0.9.18.6 did the job for me
Stock firmwares - http://xdaforums.com/showthread.php?t=2648320
Initially it worked flawlessly but then, around 50% battery level, to my dissapointment random black screens of death happened again.
So it is either hardware fault, or something get messed while flashing the different ROM builds.
Thanks for your suggestions, managed to flash the latest stock ROM with Flashtool 0.9.18.6 again.
I continued experimenting a bit with the phone, on the stock ROM the functionality seems to be fully restored, CM12 builds worked without random reboots and black screens of death too.
However upon reflashing CM13, CM14 the described issues appeared again, so there's definitely something wrong with Adrians sources.