Encoder speedup (and cleanup)