Refactored Ray class