Remove obsolete comment
Minor refactor and don't use context stack
Refactor: move to separate file