Hopefully made integer encoding more simple, modified example as well