Remove some logic errors