cleanup on reverting forloops to memcpy