Cleaned up code; modified Internet connectivity check