Refactored to include some programmatic control of the wifi chip and/or handle wifi-related issues