Use strlchr and strncmp where needed