Added TrimLeadingChar() and TrimTrailingChar()

Also additional function rework