Large change attempting to make type handling more portable.