Add type checking
Move indexes type check to where it is needed, and make indexes uniq
abbreviate type check to tc