Trying to clean up the awk code for substitution

Awk is not a pleasant language so it only sort of worked.
cleaning up unused files