You may want to check out this project:
It’s perhaps not exactly what you need but it is one way to avoid this problem.
Also see this discussion: