Minor logic fixes.