refactor toInt() and related machinery into Node