Made optimizations to class comparison