Refactor isdigit_string as common function + minor fixes.