How do you avoid favoritism and personal relationships from affecting grading?
I would suggest to design a rubric to assess the work of students. The design of a rubric is difficult and may require a lot of work for the teacher, but it will isolate the grading process from other factors. Here you can find a book about rubrics.

One of the advantages of using a rubric is that students can easily observe how their work is going to be evaluated. Another advantage is that teachers can easily apply the same criteria across all the work to be graded.