Fix some logic failures