Corrected conditionals and added protection for simultaneous master and replica configuration
Merge remote-tracking branch 'origin/master'