A huge improvement would be to use ray differentials. The broad structure is already there, but no functions to calculate and use this feature.