ray tracing
cleaned up a bit
more code cleanup for sharing