Move newArray and its relatives to util

Depends on #497.