More logic fixes