fixed some encoder bugs