Cleaned up equals so that it is easier to understand.