Keep a pointer to the repository in the objects and references

Otherwise, the garbage collector might decide it's a good idea to throw
away the repository instance while the C object still has a pointer to
it. Hilarity ensues.