tidied up parser, and remove mad characters from text