Added workspace switching and improved the Encoder constructor.