Bugfix for #473.

Waww, that was more work than I thought. :D
While coding this I came unfortunately over a couple of other bugs. We need really some more closer look over the source code and need to make through some test-cases. We should not press out new Alpha versions until that.

TODO

- [x] Remove debug stuff/clean up some shit
- [ ] Write documentation
- [x] Write full list of bug fixes
- [x] Write more tests for the more complex n:n relation tables.