Various fixes and improvements to the NetworkListenerThread class.

Change-Id: Id2525f61427708854a78325be3da8c9e688abe61