Worked out the source context in the internal module, with some refactorings to keep implementation in internal as simple as possible.
fixed everything after including AH changes