remove redundant != NULL tests before free()
check strdup(3) return values
be consistent when comparing things ('constant' on the left)