Made efficient.  2-pass, one big memory allocation.