Moved encoding to it's own file.