refactor typecodes