Fixed bugs with the ray intersection.