Various fixes and improvements to the NetworkListenerThread class.

Change-Id: Id2525f61427708854a78325be3da8c9e688abe61
Code review by Daniel

Change-Id: I7c04502efa76ec7778b419ac6036f3544b284a31