Fix missing type checks in various functions