Code clean-up, improvements for WiFi integration