Encoder Code Tested and Perfected