Code cleanup, PorgressBar and network availability error checking.
code clean up