encoder bug fix and logging