Initial implementation of encoder.