Improved module disabling code