General refactoring of raytracer