core: fix complex 'if' processing (issues #9 and #12)