Minor rework, now constructor takes encoder as argument