Merging encode/decode into single token module