Refactored volume control code.