Refactor UI code

typo fixed
Separating building components from populating them.

Clean-up.