At a first glance, the code looks alright, although it can probably be done much shorter. I'm not sure what you mean with clearing the strings. But such questions are better answered in the lite-C forum.