Bugfixes from testing