added bstrlib for safer strings
replaced strncmp with bstricmp