First version of encoder.