ADC library code refactored