Made listener thread & removed unused code