Fix a bug in redirection, also improve digit handling