Get rid of instanceOf calls