Fixed some raycasting bugs