Fix bug in set_last_char()