Fix check relationship name bug and remove unused code