Refactored webcam functionality.