added isSafe checks to calls to externalinterface