Adding instanceof verification. Seems like that is it needed in some cases.