Much more logic fixes.