Assign more suitable types and fix narrowing conversion warns.