First bugfixes and refactorings

As discussed at the meeting (19. Mar. 14).