Let javac do the type inference.
1. Implement the equals() and hashCode() functions.
2. Some other small optimizations to avoid making virtual function calls when we don't have to.