code cleanup and bug fixes
refactored code towards doing real-time spectrum analysis