Refactored laser raytracing code