sw: broke up main function into subfunctions. refactored the rx handling. started work on analog input, the AnalogIn class didn't work very well. This code probably doesn't work as good as the previous version.