String Function complete

Completed string function and did a bit of tidying up of the code,
removed unused variables.