Move ray manipulation into a separate module.