Fixes for array writing and array memory allocation.