improved z sorting
fix sort crash, towel test state