contract BasicToken is ERC20Basic {
  using SafeMath for uint;
  // users
  struct User {
    uint120 tokens; // current tokens of user
    uint120 asks;   // current tokens in asks
    uint120 votes;  // current voting power
    uint120 weis;   // current wei balance of user
    uint32 lastProposalID; // last processed dividend period of user's tokens
    address owner;  // votes for new owner
    uint8   voted;  // vote for proposal
  }
  mapping (address => User) users;

  modifier onlyPayloadSize(uint size) {
    assert(msg.data.length >= size + 4);
    _;
  }
  /**
  * @dev transfer token for a specified address
  * @param _to The address to transfer to.
  * @param _value The amount to be transferred.
  */
  function transfer(address _to, uint _value) public onlyPayloadSize(2 * 32) {
    commitDividend(msg.sender);
    users[msg.sender].tokens = uint120(uint(users[msg.sender].tokens).sub(_value));
    if(_to == address(this)) {
      commitDividend(owner);
      users[owner].tokens = uint120(uint(users[owner].tokens).add(_value));
      emit Transfer(msg.sender, owner, _value);
    }
    else {
      commitDividend(_to);
      users[_to].tokens = uint120(uint(users[_to].tokens).add(_value));
      emit Transfer(msg.sender, _to, _value);
    }
  }
  /**
  * @dev Gets the amount of tokens
  * @param _owner The address to query.
  * @return An uint representing the amount owned by the passed address.
  */
  function balanceOf(address _owner) public view returns (uint) {
    return uint(users[_owner].tokens);
  }
  /**
  * @dev Gets the amount of tokens offered for sale (in asks)
  * @param _owner The address to query.
  * @return An uint representing the amount offered by the passed address.
  */
  function askOf(address _owner) public view returns (uint) {
    return uint(users[_owner].asks);
  }
  /**
  * @dev Gets the amount of tokens offered for sale (in asks)
  * @param _owner The address to query.
  * @return An uint representing the amount offered by the passed address.
  */
  function voteOf(address _owner) public view returns (uint) {
    return uint(users[_owner].votes);
  }
  /**
  * @dev Gets the amount of wei owned by user and stored in contract
  * @param _owner The address to query.
  * @return An uint representing the amount wei stored in contract.
  */
  function weiOf(address _owner) public view returns (uint) {
    return uint(users[_owner].weis);
  }
  /**
  * @dev Gets the id of last proccesed proposal period
  * @param _owner The address to query.
  * @return An uint representing the id of last processed proposal period
  */
  function lastOf(address _owner) public view returns (uint) {
    return uint(users[_owner].lastProposalID);
  }
  /**
  * @dev Gets the proposed address of new contract owner / manager
  * @param _owner The address to query.
  * @return An address proposed as new contract owner / manager
  */
  function ownerOf(address _owner) public view returns (address) {
    return users[_owner].owner;
  }
  /**
  * @dev Gets the status of voting
  * @param _owner The address to query.
  * @return An uint > 0 if user already voted
  */
  function votedOf(address _owner) public view returns (uint) {
    return uint(users[_owner].voted);
  }
}
function askOf(address _owner) public view returns (uint) {
  return uint(users[_owner].asks);
}

/**
 * @dev Gets the amount of tokens offered for sale (in asks)
 * @param _owner The address to query.
 * @return An uint representing the amount offered by the passed address.
 */