bugfixes, added some checks in string functions