refactor the tie case and some p8 issues