General bugfixes

Bugfixes/improvements are in commit messages.