Improved raycasting