Fixing wrong cast inside equals method.