Optimizations

Use array join instead of string concatenation when building the HTML;
Pinpoint elements using index instead of DOM search;