Code refactored and multi device support

Refactoring of AtoD for simplified interfacing.