ERC20 token for BSC: Can't create liquidity pool with custom _transfer function. Where could the problem be?

Hi all,

I've been working on a unique BSC contract that is a fork of 'automatic BUSD redistribution' contracts. The differences here are twofold:
a) users will not be able to sell any tokens
b) there is a 'mint' function at the point of every buy

I have used code from this token which restricts selling to specific minutes in an hour, and extended that concept to try and prevent all selling.
That contract uses specific information to figure out if a transaction is a liquidity transfer and does not apply restrictions to such transactions. I'll include all relevant code below.

While my contract compiles and I deployed it from Remix, I can't add liquidity to it on pancake swap. After approving, when I go to actually 'add' it, pancake swap doesn't respond. I strongly suspect there is an issue with my 'transfer' function but can't quite place my finger on it.

My 'transfer' functions are below:

function _transfer(
        address from,
        address to,
        uint256 amount
    ) internal override {
        require(from != address(0), "ERC20: transfer from the zero address");
        require(to != address(0), "ERC20: transfer to the zero address");
        bool isExcluded = isExcludedFromFees(from) || isExcludedFromFees(to);
        bool isContractTransfer = (from==address(this) || to==address(this)); //from antiG, 

        address uniswapV2RouterAddress = address(uniswapV2Router);
        bool isLiquidityTransfer = ((from == uniswapV2Pair && to == uniswapV2RouterAddress)
        || (to == uniswapV2Pair && from == uniswapV2RouterAddress));

        if(isContractTransfer || isLiquidityTransfer || isExcluded) {
            super._transfer(from, to, amount); //note: this one emits anyway 
        } else {
           // require(tradingIsEnabled,"Trading not yet enabled");
            bool isBuy= from==uniswapV2Pair|| from == uniswapV2RouterAddress;
            bool isSell= to==uniswapV2Pair|| to == uniswapV2RouterAddress;
            _redistributiveTransfer(from, to, amount, isBuy, isSell);   

    //stack can only be 7 deep so we split into two functions
    function _redistributiveTransfer(address from, address to, uint256 amount, bool isBuy, bool isSell) private{
        if(isSell) {
                require(false, "can't sell this one!");
            } else {
                uint256 contractBalanceRecepient = balanceOf(to);
                    contractBalanceRecepient + amount <= maxWalletToken,
                    "Exceeds maximum wallet token amount."

                uint256 contractTokenBalance = balanceOf(address(this));
                bool canSwap = contractTokenBalance >= swapTokensAtAmount;
                if (!swapping && canSwap) {
                    swapping = true;
                    uint256 sellTokens = balanceOf(address(this));
                    swapping = false;

                bool mintTokens = !swapping;

                if(mintTokens) {
                    _mint(address(this), amount.mul(percentageRedistributed).div(100) * (10**18));

                super._transfer(from, to, amount);

                try dividendTracker.setBalance(payable(from), balanceOf(from)) {} catch {}
                try dividendTracker.setBalance(payable(to), balanceOf(to)) {} catch {}

                if(!swapping) {
                    uint256 gas = gasForProcessing;

                    try dividendTracker.process(gas) returns (uint256 iterations, uint256 claims, uint256 lastProcessedIndex) {
                        emit ProcessedDividendTracker(iterations, claims, lastProcessedIndex, true, gas, tx.origin);
                    catch {


I'll also include the code that created some of the above variables. I'm also happy to send the full contract code by PM to anyone who thinks they can help.

Select code from the constructor:

IUniswapV2Router02 _uniswapV2Router = IUniswapV2Router02(0x10ED43C718714eb63d5aA57B78B54704E256024E);//BUB: 0x10 address is pancakeSwapV2 mainnet router //0x9Ac64Cc6e4415144C455BD8E4837Fea55603e5c3
         // Create a uniswap pair for this new token
        address _uniswapV2Pair = IUniswapV2Factory(_uniswapV2Router.factory())
            .createPair(address(this), _uniswapV2Router.WETH());

        uniswapV2Router = _uniswapV2Router;
        uniswapV2Pair = _uniswapV2Pair;

Thanks to anyone that can help