Improve complex boolean expression handling