Replaced substr_compare with strncmp where possible