Added ASCII/EBCDIC type checking. Refactored and eliminated some unnecessary code.