Futher efactoring to allow raycasting implementation.