use unsigned types, cc+nested branch fix, var type cast