fix wrong predicate in conditional
misc small improvements