Fix arrayindexoutofbound and concurrentmodificationexception