Encoder code working. Tested.