Fixed the scale calculations
memory optimization for AVR and bug fixed with slew on AVR