Type conversion fixes.

Closes #313.