Replace HashMap by LongSparseArray for performance