Cleanup code a little
Fix network check code