cleanup, signedness, range checking (#3472)