Deflationary token with owner wallet


This is the simple code I have created for deflationary token I want to deploy. The tokenomics is quite simple:

  • a percentage gets burned (hard burned, remove from total supply)
  • a percentage goes to the owner.

A already know I have two main issues with this testing it a bit on remix:

  • When you change the owner, the burn and tax doesn't work anymore
  • I am trying to create cap burn but no matter what I do it doesn't work (I have commented one of the tries)

Would appreciate any review, feedback and support to fix those issues. Cheers

// SPDX-License-Identifier: MIT
// OpenZeppelin Contracts v4.3.2 (token/ERC20/ERC20.sol)

pragma solidity ^0.8.0;


contract Gayo is ERC20, ERC20Burnable, Ownable {
    using SafeMath for uint256;
    using Address for address;
    uint Dev_Fee = 1;
    uint Burn_Fee= 1;
    uint256 internal TOTALSUPPLY = 500000 * 10**0;
    uint256 internal basePercent = 100;
    uint256 public _burnStopAmount;
    //address public owner;
    mapping(address => bool) internal ExcludedFromFee;
    constructor() public ERC20('Gayo', 'Gayo') {
        _mint(owner(), TOTALSUPPLY);
        //owner = owner();
        ExcludedFromFee[owner()] = true;
        _burnStopAmount = TOTALSUPPLY/10;

    function transfer(address recipient, uint256 amount) public override returns(bool) {
        if(ExcludedFromFee[msg.sender] == true) {
            _transfer(_msgSender(), recipient, amount);
        //else if(TOTALSUPPLY <= _burnStopAmount) {
        //    uint ownerAmount = amount.mul(Dev_Fee)/ basePercent;
        //    _transfer(_msgSender(), owner(), ownerAmount);
        //    _transfer(_msgSender(), recipient, amount.sub(ownerAmount));
        else {
            uint burntAmount = amount.mul(Burn_Fee) / basePercent;
            uint ownerAmount = amount.mul(Dev_Fee)/ basePercent;
            _burn(_msgSender(), burntAmount);
            _transfer(_msgSender(), owner(), ownerAmount);
            _transfer(_msgSender(), recipient, amount.sub(burntAmount).sub(ownerAmount));
        return true;