Use better method to determine if activate and deactivate are being sourced

See http://stackoverflow.com/a/2684300/161801