Fix issues with usage of instanceof.