Add reset to encoder and some debug