Completed get_digits function and all its dependents.