contract AppProxyBase is IAppProxy, AppStorage, DelegateProxy, KernelConstants {
    /**
    * @dev Initialize AppProxy
    * @param _kernel Reference to organization kernel for the app
    * @param _appId Identifier for app
    * @param _initializePayload Payload for call to be made after setup to initialize
    */
    function AppProxyBase(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
        kernel = _kernel;
        appId = _appId;

        // Implicit check that kernel is actually a Kernel
        // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
        // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
        // it.
        address appCode = getAppBase(appId);

        // If initialize payload is provided, it will be executed
        if (_initializePayload.length > 0) {
            require(isContract(appCode));
            // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
            // returns ending execution context and halts contract deployment
            require(appCode.delegatecall(_initializePayload));
        }
    }

    function getAppBase(bytes32 _appId) internal view returns (address) {
        return kernel.getApp(keccak256(APP_BASES_NAMESPACE, _appId));
    }

    function () payable public {
        address target = getCode();
        require(target != 0); // if app code hasn't been set yet, don't call
        delegatedFwd(target, msg.data);
    }
}
function AppProxyBase(IKernel _kernel, bytes32 _appId, bytes _initializePayload) public {
    kernel = _kernel;
    appId = _appId;

    // Implicit check that kernel is actually a Kernel
    // The EVM doesn't actually provide a way for us to make sure, but we can force a revert to
    // occur if the kernel is set to 0x0 or a non-code address when we try to call a method on
    // it.
    address appCode = getAppBase(appId);

    // If initialize payload is provided, it will be executed
    if (_initializePayload.length > 0) {
        require(isContract(appCode));
        // Cannot make delegatecall as a delegateproxy.delegatedFwd as it
        // returns ending execution context and halts contract deployment
        require(appCode.delegatecall(_initializePayload));
    }
}

/**
 * @dev Initialize AppProxy
 * @param _kernel Reference to organization kernel for the app
 * @param _appId Identifier for app
 * @param _initializePayload Payload for call to be made after setup to initialize
 */