Rearanged some code

Reorganized the code structur for better overview and as a preparation
for the vertical rendering option.