Tidy up code; add core String extension.