Bugfixes found while testing