A few speedup improvements.

Basically avoiding creation of objects and arrays whenever possible.

http://jsperf.com/merge-test