Refactor big number encoding.