v.20.3Performance Improvement

Simplified and Optimized Code for Logical Functions

Simpler and more efficient code in Logical Functions + code cleanups. A followup to #8718 #8728 (Alexander Kazakov)