Optimized the line sphere intersection code