some fixes, still not treating rays correctly