Minor logic fixes1