Creating m2m relationships that use a through class

A possible solution for issue #931, which I opened recently. This has solved the problem I was experiencing.

Still working on a test case for it.