optimized the disable/enable code (only run on connect/disconnect and only do minimal work)