KeyError bugfix backported from devel.
Infinite loop bugfix backported from devel.
Merge pull request #231 from boudewijn-tribler/release-6.1

Bugfixes.