Many little adjustment & bugfixes

@pjedrzejewski Please have a look at this, without this PR your refactoring one is not usable =)