Cleaned up code to solve issues with camera.