Make invokeEncoder play nice with polymorphism.
Merge pull request #18 from thabach/master

Make invokeEncoder play nice with polymorphism.