Refactor encoded device support

Put all code related to encoded devices in to a single source file.
Prevents code from having to be duplicated for each and every single
encoded device.