Improved implementation of equals & hashCode