Improved entity checks to cover even more edge cases.