Fix potential bugs involved with array hash code and synchronized