Removed the background thread, moved code to the interrupt handler & receive. Fixed a few bugs.