Possibly fixing some logic issues