Refactored raycaster from past project.