For ENG-5400, more k-safety work and some performance improvements to leader elector

For ENG-5400, fix compile error and exception handling