fix memory errors due to too-large memcpy in ArrayList