Implement string_of and fix a memory leak in string_from