Fixed bug with encoder
Fixed bug with encoder
Pulling in upstream changes while retaining speed optimizations
Merge pull request #32 from dave-andersen/master

Full pull request for algorithmic optimizations with bug fix.