Made vars global, create thread for receiving msgs