Tried a few things from the previous page in order to fix the speakerphone problem.
Since speakerphone was not working on CM 13, I downloaded CM 12.1 from 27 January. I did not download corresponding GApps.
Now, I copied over the file to the device and rebooted to recovery.
Then, I wiped everything other than internal data and then flashed CM 12.1
I could not test if speakerphone worked, because after CM 12.1 was booted, the device would reboot after the 'configure WiFi' stage.
Then I flashed CM 13 and OpenGapps after a factory reset. The speakerphone did not work. The torch worked though in my case, unlike someone else's observation above.
Now, I am trying to restore the device to 5.1 (from Team Exodus).
Edit: Restoring to 5.1 (Team Exodus) landed me into trouble. After restoration, the phone got stuck in the animation.
So, I decided to go back to stock 4.4.
I tried to restore my backup from TWRP (to my stock 4.4). I selected only system and data (unselected boot) in the Restore screen inside TWRP.
Now, I am not sure if that was the right thing to do. The phone got stuck on the "Warning bootloader unlocked" screen.
Adding some of my notes here as I progressed....
So, I again went into Recovery and this time I did a format of cache, dalvik and system. Then tried to restore my
stock 4.4
Again back in the "Warning bootloader unlocked" screen. The phone is sitting on that screen since 3 minutes.
So, again rebooted to Recovery and this time I am trying to restore System, Data and Boot partition. Without this,
the phone is not booting into Android it seems.
So, flashing the boot partition above seems to work. Now, I get the familiar "Droid.." sound.
I was back on Stock 4.4.4
Now, inside recovery, I wiped cache, data, dalvik and system (did not touch internal storage)
Installed CM 12.1
This time CM 12.1 did not have any crashes. I made a test call. Speakerphone did not work.
Rebooted to recovery and did a factory reset. Then installed CM 13 followed by GApps. Rebooted.
Speakerphone still does not work.
The only thing I have not done is wipe "Internal Storage". I don't know if that could be affecting somehow.