cleaned up the various raycasting functions