Fixes to boolean logic