Separate element creation and event init

Also fix some tab errors, do some renaming of functions and change some
css style classes. This should really have been split up in separate
patches...