Use suitable types for variables.

Similar to #988.