Bug #1 - don't use innerHTML.

Also refactor the code a bit

Fix an iteration bug from the DOM.