contract Ownable {
  address public owner;
  bool public canRenounce = false;
  mapping (address => bool) public authorities;

  event OwnershipTransferred(address indexed previousOwner, address indexed newOwner);
  event AuthorityAdded(address indexed authority);
  event AuthorityRemoved(address indexed authority);

  /**
   * @dev The Ownable constructor sets the original `owner` of the contract to the sender account.
   */
  constructor() public {
    owner = msg.sender;
  }

  /**
   * @dev Throws if called by any account other than the owner.
   */
  modifier onlyOwner() {
    require(msg.sender == owner);
    _;
  }

  /**
   * @dev Throws if called by any account other than the authority or owner.
   */
  modifier onlyAuthority() {
      require(msg.sender == owner || authorities[msg.sender]);
      _;
  }

  /**
   * @dev Allows the current owner to relinquish control of the contract.
   */
  function enableRenounceOwnership() onlyOwner public {
    canRenounce = true;
  }

  /**
   * @dev Allows the current owner to transfer control of the contract to a newOwner.
   * @param _newOwner The address to transfer ownership to.
   */
  function transferOwnership(address _newOwner) onlyOwner public {
    if(!canRenounce){
      require(_newOwner != address(0));
    }
    emit OwnershipTransferred(owner, _newOwner);
    owner = _newOwner;
  }

  /**
   * @dev Adds authority to execute several functions to subOwner.
   * @param _authority The address to add authority to.
   */

  function addAuthority(address _authority) onlyOwner public {
    authorities[_authority] = true;
    emit AuthorityAdded(_authority);
  }


  /**
   * @dev Removes authority to execute several functions from subOwner.
   * @param _authority The address to remove authority from.
   */

  function removeAuthority(address _authority) onlyOwner public {
    authorities[_authority] = false;
    emit AuthorityRemoved(_authority);
  }
}
/**
 * @title Ownable
 * @dev The Ownable contract has an owner address & authority addresses, and provides basic
 * authorization control functions, this simplifies the implementation of user permissions.
 */
function transferOwnership(address _newOwner) onlyOwner public {
  if(!canRenounce){
    require(_newOwner != address(0));
  }
  emit OwnershipTransferred(owner, _newOwner);
  owner = _newOwner;
}

/**
 * @dev Allows the current owner to transfer control of the contract to a newOwner.
 * @param _newOwner The address to transfer ownership to.
 */