Various fixes

Includes fixes for https://github.com/Tribler/tribler/issues/398, https://github.com/Tribler/tribler/issues/410, and a few others