Added EncoderFactory class.
Improved exception handling.