Optimized loops to cache array lengths. Changed createElements to use cloneNode(true) where appropriate. Using local variable where appropriate.