recoded the entire sh.c file, still there is some work to be done.