Handle template associations better