Channels relation

I’m working with Asterisk from about one years and, now I’d like to start to develop new module for call control purpose. I’ve created a small application which give me the ability to build the relation between channels, so I can know what channel is connected with one other. This application is only a beta one (very experimental) , because there are many conditions that I haven’t covered yet. I’ve had some problems when Asterisk use Local channels. It is difficult to follow all operations that Asterisk performs.
Could someone give me some hints?