Instanceof check is faster and basically equivalent to old logic.