remove hits.Reverse()
fix lost material bug; several minor changes