Templated the code

Separated the code concerning various different UI components and
created Template kind structure.