Making encoding configurable. Still need better interface